Skip to content

Commit 8769b06

Browse files
committed
update doc
1 parent 2c4bdba commit 8769b06

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Egrid
22

3-
## 基于 `Element-UI` `Table` 组件封装的高阶表格组件。
3+
### 基于 `Element-UI` `Table` 组件封装的高阶表格组件,可无缝支持 element 的 table 组件
44

55
文档 [http://kinglisky.github.io/egrid](http://kinglisky.github.io/egrid)
66

7+
78
### 开发
89

910
> `npm run dev`
@@ -32,6 +33,7 @@ import Vue from 'vue'
3233
import Egrid from 'egrid'
3334

3435
// table 的样式需要手动引入
36+
import 'element-ui/lib/theme-default/icon.css'
3537
import 'element-ui/lib/theme-default/table.css'
3638
import 'element-ui/lib/theme-default/table-column.css'
3739

@@ -87,4 +89,6 @@ Vue.use(Egrid)
8789
如果每次使用表格都要重复这一段代码,那久而久之你的项目肯定会冗余很多重复的代码,而且也不利于维护。
8890
这时候我们就有必要在原始的表格组件基础上再封装一层,将这些重复的代码放在组件内部,使用时考虑如何通过一种配置的方式去定制表格。
8991

92+
`egrid` 就是为此而生的,少写两行是两行。耶~~~
93+
9094

docs/README.md

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Egrid
22

3-
基于 `Element-UI` `Table` 组件封装的高阶表格组件。
3+
基于 `Element-UI` `Table` 组件封装的高阶表格组件,可无缝支持 element 的 table 组件
44

5-
min 大小仅 4kb。实现比较简单,源码在这: [https://github.com/kinglisky/egrid](https://github.com/kinglisky/egrid)
5+
min 文件仅 3.8 kb。实现比较简单,源码在这: [https://github.com/kinglisky/egrid](https://github.com/kinglisky/egrid)
66

77
首先组件依赖 `Element Table`,先要安装 Element:
88

@@ -22,6 +22,7 @@ import Vue from 'vue'
2222
import Egrid from 'egrid'
2323

2424
// table 的样式需要手动引入
25+
import 'element-ui/lib/theme-default/icon.css'
2526
import 'element-ui/lib/theme-default/table.css'
2627
import 'element-ui/lib/theme-default/table-column.css'
2728

@@ -33,7 +34,7 @@ Vue.use(Egrid)
3334
src="//jsfiddle.net/nlush/yr0uf0fm/7/embedded/result,html,js,css/" allowfullscreen="allowfullscreen" frameborder="0">
3435
</iframe>
3536

36-
表格中自定义渲染的组件
37+
先创建表格中使用的自定义组件
3738

3839
`cell-btn.vue`
3940
```html
@@ -105,7 +106,7 @@ export default {
105106
return {
106107
data: Data.data,
107108
columns: Data.columns,
108-
// columnsProps 用于定义 columns 公共的属性
109+
// columnsProps 用于定义 columns 公共的属性
109110
columnsProps: {
110111
width: 120,
111112
sortable: true,
@@ -117,7 +118,7 @@ export default {
117118
columnsSchema: {
118119
'地址': {
119120
width: 'auto',
120-
// propsHandler 可用于转换传给自定义组件的 props
121+
// propsHandler 可用于转换传给自定义组件的 props 这里将 props 变成了 address
121122
propsHandler ({ col, row }) {
122123
return { address: row[col.prop] }
123124
},
@@ -162,7 +163,7 @@ export default {
162163

163164
# Attributes
164165

165-
!> `egrid` 只是在 `Element Table` 封装了一层,原本设置在 `Table` 上的 `props` 与事件监听可直接设置到 `egrid` 上,如:`height` `max-height` `border` `@selection-change`......可参考[Element Tabel 文档](http://element.eleme.io/#/zh-CN/component/table#table-attributes)
166+
!> `egrid` 只是在 `Element Table` 封装了一层,原本设置在 `Table` 上的 `props` 与事件监听可直接设置到 `egrid` 上,如:`height` `max-height` `border` `@selection-change`......具体配置可参考[Element Tabel 文档](http://element.eleme.io/#/zh-CN/component/table#table-attributes)
166167

167168
| 属性 | 说明 | 可选项 | 默认 |
168169
| --- | ---- | --- | --- |
@@ -222,7 +223,7 @@ const columns = [
222223
`listeners`
223224
用于监听 `component` 配置的自定义渲染组件内部 `$emit` 出的事件,这里使用 Vue 2.4 引入 `v-on` [新语法](https://cn.vuejs.org/v2/api/#v-on),可直接为 `v-on` 绑定一个对象,如:
224225
```javascrip
225-
{ 'custom-event': function (data) {...} }
226+
v-on="{ 'custom-event': function (data) {...} }"
226227
```
227228

228229
`propsHandler`
@@ -236,11 +237,9 @@ const columns = [
236237
可通过 `propsHandler``{ row, col, column }` 进行转化你想要的形式:
237238

238239
```javascript
239-
propsHandler({
240-
row, col, column
241-
})
240+
propsHandler({ row, col, column })
242241

243-
转化成 =>
242+
// 转化成 =>
244243

245244
{
246245
msg: row[col.prop],
@@ -252,7 +251,7 @@ propsHandler({
252251
```
253252
> columns-props 配置
254253
255-
`columns-props` 配置用于定义 `columns` 各列默认的 props 属性。如所有的列默认都居左对齐,不支持排序,我们可以将 columns-props 设置成:
254+
`columns-props` 配置用于定义 `columns` 各列默认的 props 属性。如所有的列默认都**居左对齐****不支持排序**,我们可以将 columns-props 设置成:
256255

257256
```javascript
258257
{
@@ -278,7 +277,7 @@ propsHandler({
278277

279278
```
280279

281-
`columns-schema` 是通过 columns 每列的 `label` 属性值来匹配的。这里的配置属性会覆盖 `columns-props``columns` 设置对应的列的属性值
280+
`columns-schema` 是通过 columns 每列的 `label` 属性值来匹配的。这里的配置属性会覆盖 `columns-props``columns` 设置的对应的列的属性值
282281

283282
!> 覆盖的优先级为 `columns-schema` > `columns` > `columns-props`
284283

@@ -308,31 +307,35 @@ columnsHandler (cols) {
308307

309308
* `expand`: 表格支持折叠展开行
310309

311-
`column-type``expand` 时表格支持折叠展开行,此时可用通过 `slot(slot="expand")` 方式自定渲染折叠详情。
310+
`column-type``expand` 时表格支持折叠展开行,此时可用通过 `slot (slot="expand")` 方式自定渲染折叠详情。
312311

313-
`column-type` 为数组时可设置多个特殊列,`['expand', 'index', 'selection']`
312+
`column-type` 为数组时可设置多个特殊列,`['expand', 'index', 'selection']`,一般很少这样使用
314313

315314
使用可参考下面的栗子🌰 :
316315

317316
<iframe width="100%" height="600"
318-
src="//jsfiddle.net/nlush/azr14zfs/3/embedded/result,html,js,css/" allowfullscreen="allowfullscreen" frameborder="0">
317+
src="//jsfiddle.net/nlush/azr14zfs/3/embedded/result,html,js,css/"
318+
allowfullscreen="allowfullscreen" frameborder="0">
319319
</iframe>
320320

321321
> `column-key-map` 配置
322322
323323
考虑到 `columns` 中的 `label` 项与 `prop` 项对应的属性 key 不一定是 `label``prop`,这时可以通过 `column-key-map` 做个映射。
324324

325+
326+
325327
# Methods
326328

327329
`clearSelection` `toggleRowSelection` `setCurrentRow`
328330

329331
!> 直接代理一层原 `Element Table` 的方法。可参考[文档](http://element.eleme.io/#/zh-CN/component/table#table-methods)
330332

333+
331334
# Slots
332335

333-
`append`:对应 `Element Table``slot="append"`[文档](http://element.eleme.io/#/zh-CN/component/table#table-slot)
336+
`append`:对应 `Element Table``slot="append"` [可参考文档](http://element.eleme.io/#/zh-CN/component/table#table-slot),使用时注意设置 `slot-append``true`
334337

335-
`expand`: 当 `column-type``expand` 时自定义,行折叠内容的
338+
`expand`: 当 `column-type``expand` 时使用,用于自定义折叠展开内容
336339

337340

338341

0 commit comments

Comments
 (0)