2016-07-27 14:15:02 +08:00
|
|
|
|
<script>
|
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
2016-09-19 17:55:44 +08:00
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
|
|
|
|
}, {
|
2016-07-27 14:15:02 +08:00
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}],
|
|
|
|
|
tableData2: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
$info: true
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
$positive: true
|
|
|
|
|
}],
|
|
|
|
|
tableData3: [{
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-08',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-06',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-07',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}],
|
|
|
|
|
singleSelection: {},
|
|
|
|
|
multipleSelection: []
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
2016-08-16 16:07:18 +08:00
|
|
|
|
methods: {
|
|
|
|
|
handleSelectionChange(val) {
|
|
|
|
|
this.singleSelection = val;
|
|
|
|
|
},
|
|
|
|
|
|
2016-08-16 16:52:43 +08:00
|
|
|
|
handleMultipleSelectionChange(val) {
|
|
|
|
|
this.multipleSelection = val;
|
2016-08-23 15:24:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
formatter(row, column) {
|
|
|
|
|
return row.address;
|
2016-08-16 16:52:43 +08:00
|
|
|
|
}
|
2016-08-16 16:07:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
watch: {
|
|
|
|
|
singleSelection(val) {
|
|
|
|
|
console.log('selection: ', val);
|
|
|
|
|
},
|
|
|
|
|
|
2016-08-16 16:52:43 +08:00
|
|
|
|
multipleSelection(val) {
|
|
|
|
|
console.log('selection: ', val);
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
## Table 表格
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
用于展示多条结构类似的数据,可对数据进行排序、筛选、对比或其他自定义操作。
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 基础表格
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
基础的表格展示用法。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 当`el-table`元素中注入`data`对象数组后,在`el-table-column`中用`property`属性来对应对象中的键名即可填入数据,用`label`属性来定义表格的列名。可以使用`width`属性来定义列宽。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
2016-08-26 18:34:54 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}]
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</script>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 带斑马纹表格
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
使用带斑马纹的表格,可以更容易区分出不同行的数据。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo `stripe`属性可以创建带斑马纹的表格。它接受一个`Boolean`,默认为`false`,设置为`true`即为启用。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
stripe
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 带边框表格
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 默认情况下,Table 组件是不具有竖直方向的边框的,如果需要,可以使用`border`属性,它接受一个`Boolean`,设置为`true`即可启用。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
border
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 带状态表格
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
可将表格内容 highlight 显示,方便区分「成功、信息、警告、危险」等内容。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 为行添加自定义背景色,表明该行处于某种状态。若某一行拥有`custom-criteria`数组中的某个字段且值为`true`,则为该行添加`custom-background-colors`数组中对应的背景色。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData2"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%"
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:custom-criteria="['$info', '$positive']"
|
|
|
|
|
:custom-background-colors="['#C9E5F5', '#E2F0E4']">
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
2016-08-26 18:34:54 +08:00
|
|
|
|
property="address"
|
2016-08-26 19:46:45 +08:00
|
|
|
|
label="地址">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData2: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
$info: true
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
$positive: true
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 固定表头
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
纵向内容过多时,可选择固定表头。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 只要在`el-table`元素中定义了`height`属性,即可实现固定表头的表格,而不需要额外的代码。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 18:34:54 +08:00
|
|
|
|
<el-table
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:data="tableData3"
|
|
|
|
|
height="250"
|
|
|
|
|
border
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
2016-08-16 16:07:18 +08:00
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData3: [{
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-08',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-06',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-07',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 固定列
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
横向内容过多时,可选择固定首列。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 固定列需要使用`fixed-column-count`属性,它接受一个`Number`,表示左起要固定的列数。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:fixed-column-count="1"
|
|
|
|
|
border
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
|
|
|
|
width="150">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="province"
|
|
|
|
|
label="省份"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="city"
|
|
|
|
|
label="市区"
|
|
|
|
|
width="120">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址"
|
|
|
|
|
width="300">
|
|
|
|
|
</el-table-column>
|
2016-09-19 17:55:44 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="zip"
|
|
|
|
|
label="邮编"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
2016-09-19 17:55:44 +08:00
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
|
|
|
|
}, {
|
2016-07-27 14:15:02 +08:00
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 固定列和表头
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
横纵内容过多时,可选择固定列和表头。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 固定列和表头可以同时使用,只需要将上述两个属性分别设置好即可。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData3"
|
|
|
|
|
:fixed-column-count="1"
|
|
|
|
|
border
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%"
|
2016-08-26 19:46:45 +08:00
|
|
|
|
height="250">
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
|
|
|
|
width="150">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="province"
|
|
|
|
|
label="省份"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="city"
|
|
|
|
|
label="市区"
|
|
|
|
|
width="120">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址"
|
|
|
|
|
width="300">
|
|
|
|
|
</el-table-column>
|
2016-09-19 17:55:44 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="zip"
|
|
|
|
|
label="邮编"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData3: [{
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-08',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-06',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-07',
|
|
|
|
|
name: '王小虎',
|
2016-09-19 17:55:44 +08:00
|
|
|
|
province: '上海',
|
|
|
|
|
city: '普陀区',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
zip: 200333
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 单选
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
选择单行数据时使用色块表示。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo Table 组件提供了选择的支持,只需要配置`selection-mode`属性即可实现单选(`single`)、多选(`multiple`),如果不需要则设置为`none`。之后由`selectionchange`事件来管理选中时触发的事件,它会传入一个`value`,`value`为生成表格时的对应对象。本例中还使用了`allow-no-selection`属性,它接受一个`Boolean`,若为`true`,则允许为空,默认为`false`,此时将会产生默认值,为填入数组的第一个对象。如果需要显示索引,可以增加一列`el-table-column`,设置`type`属性为`index`即可显示从 1 开始的索引号。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
selection-mode="single"
|
|
|
|
|
@selectionchange="handleSelectionChange"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%"
|
2016-08-26 19:46:45 +08:00
|
|
|
|
allow-no-selection>
|
|
|
|
|
<el-table-column
|
|
|
|
|
type="index"
|
|
|
|
|
width="50">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}],
|
|
|
|
|
singleSelection: {}
|
|
|
|
|
}
|
2016-08-16 16:07:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
handleSelectionChange(val) {
|
|
|
|
|
this.singleSelection = val;
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 多选
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
选择多行数据时使用 Checkbox。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-02 13:56:47 +08:00
|
|
|
|
:::demo 除了`selection-mode`的设置外,多选与单选并没有太大差别,只是传入`selectionchange`事件中的参数从对象变成了对象数组。此外,需要提供一个列来显示多选框: 手动添加一个`el-table-column`,设`type`属性为`selection`即可。在本例中,为了方便说明其他属性,我们还使用了`inline-template`和`show-tooltip-when-overflow`:设置了`inline-template`属性后,可以通过调用`row`对象中的值取代`property`属性的设置;默认情况下若内容过多会折行显示,若需要单行显示可以使用`show-tooltip-when-overflow`属性,它接受一个`Boolean`,为`true`时多余的内容会在 hover 时以 tooltip 的形式显示出来。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData3"
|
|
|
|
|
selection-mode="multiple"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%"
|
2016-08-26 19:46:45 +08:00
|
|
|
|
@selectionchange="handleMultipleSelectionChange">
|
|
|
|
|
<el-table-column
|
|
|
|
|
type="selection"
|
|
|
|
|
width="50">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
inline-template
|
|
|
|
|
label="日期"
|
|
|
|
|
width="120">
|
2016-08-16 16:07:18 +08:00
|
|
|
|
<div>{{ row.date }}</div>
|
|
|
|
|
</el-table-column>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
|
|
|
|
width="120">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址"
|
|
|
|
|
show-tooltip-when-overflow>
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData3: [{
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-08',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-06',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-07',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}],
|
|
|
|
|
multipleSelection: []
|
|
|
|
|
}
|
2016-08-16 16:07:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
handleSelectionChange(val) {
|
|
|
|
|
this.multipleSelection = val;
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### 排序
|
2016-08-23 15:24:26 +08:00
|
|
|
|
|
2016-09-08 09:15:35 +08:00
|
|
|
|
对表格进行排序,可快速查找或对比数据。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::demo 在列中设置`sortable`属性即可实现以该列为基准的排序,接受一个`Boolean`,默认为`false`。在本例中,我们还使用了`formatter`属性,它用于格式化指定列的值,接受一个`Function`,会传入两个参数:`row`和`column`,可以根据自己的需求进行处理。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
border
|
2016-09-19 17:55:44 +08:00
|
|
|
|
style="width: 100%">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
property="date"
|
|
|
|
|
label="日期"
|
|
|
|
|
sortable
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="name"
|
|
|
|
|
label="姓名"
|
2016-09-19 17:55:44 +08:00
|
|
|
|
width="180">
|
2016-08-26 19:46:45 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
property="address"
|
|
|
|
|
label="地址"
|
|
|
|
|
:formatter="formatter">
|
|
|
|
|
</el-table-column>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tableData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}]
|
|
|
|
|
}
|
2016-08-23 15:24:26 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
formatter(row, column) {
|
|
|
|
|
return row.address;
|
|
|
|
|
}
|
2016-07-27 14:15:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
```
|
2016-08-26 19:46:45 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### Table Attributes
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| data | 显示的数据 | array | — | — |
|
|
|
|
|
| height | table 的高度,默认高度为空,即自动高度 | string | — | — |
|
|
|
|
|
| stripe | 是否为斑马纹 table | boolean | — | false |
|
|
|
|
|
| border | 是否带有纵向边框 | boolean | — | false |
|
2016-08-26 19:46:45 +08:00
|
|
|
|
| selection-mode | 列表项选择模式 | string | single/multiple/none | none |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| allow-no-selection | 单选模式是否允许选项为空 | boolean | — | false |
|
|
|
|
|
| fixed-column-count | 固定列的个数 | number | — | 0 |
|
2016-08-26 19:46:45 +08:00
|
|
|
|
|
|
|
|
|
### Table Events
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 事件名 | 说明 | 参数 |
|
|
|
|
|
| ---- | ---- | ---- |
|
2016-08-16 16:07:18 +08:00
|
|
|
|
| selectionchange | 当选择项发生变化时会触发该事件 | selected |
|
|
|
|
|
| cellmouseenter | 当单元格 hover 进入时会触发该事件 | row, column, cell, event |
|
|
|
|
|
| cellmouseleave | 当单元格 hover 退出时会触发该事件 | row, column, cell, event |
|
|
|
|
|
| cellclick | 当某个单元格被点击时会触发该事件 | row, column, cell, event |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 19:46:45 +08:00
|
|
|
|
### Table-column Attributes
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| label | 显示的标题 | string | — | — |
|
|
|
|
|
| property | 对应列内容的字段名 | string | — | — |
|
|
|
|
|
| width | 对应列的宽度 | string | — | — |
|
|
|
|
|
| sortable | 对应列是否可以排序 | boolean | — | false |
|
|
|
|
|
| type | 对应列的类型。如果设置了 `selection` 则显示多选框,如果设置了 `index` 则显示该行的索引(从 1 开始计算) | string | selection/index | — |
|
|
|
|
|
| formatter | 用来格式化内容,在 formatter 执行的时候,会传入 row 和 column | function | — | — |
|
|
|
|
|
| show-tooltip-when-overflow | 当过长被隐藏时显示 tooltip | Boolean | — | false |
|
|
|
|
|
| inline-template | 指定该属性后可以自定义 column 模板,参考多选的时间列,通过 row 获取行信息,JSX 里通过 _self 获取当前上下文。此时不需要配置 property 属性 | — | — |
|