2018-04-01 04:52:27 +00:00
|
|
|
<cn>
|
|
|
|
#### template 风格的 API
|
|
|
|
使用 template 风格的 API
|
|
|
|
> 这个只是一个描述 `columns` 的语法糖,所以你不能用其他组件去包裹 `Column` 和 `ColumnGroup`。
|
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
|
|
|
#### template style API
|
|
|
|
Using template style API
|
|
|
|
> Since this is just a syntax sugar for the prop `columns`, so that you can't compose `Column` and `ColumnGroup` with other Components.
|
|
|
|
</us>
|
|
|
|
|
2019-10-09 10:32:23 +00:00
|
|
|
```tpl
|
2018-04-01 04:52:27 +00:00
|
|
|
<template>
|
|
|
|
<a-table :dataSource="data">
|
|
|
|
<a-table-column-group>
|
|
|
|
<span slot="title" style="color: #1890ff">Name</span>
|
2019-09-28 12:45:07 +00:00
|
|
|
<a-table-column dataIndex="firstName" key="firstName">
|
2018-04-01 04:52:27 +00:00
|
|
|
<span slot="title" style="color: #1890ff">First Name</span>
|
|
|
|
</a-table-column>
|
2019-09-28 12:45:07 +00:00
|
|
|
<a-table-column title="Last Name" dataIndex="lastName" key="lastName" />
|
2018-04-01 04:52:27 +00:00
|
|
|
</a-table-column-group>
|
2019-09-28 12:45:07 +00:00
|
|
|
<a-table-column title="Age" dataIndex="age" key="age" />
|
|
|
|
<a-table-column title="Address" dataIndex="address" key="address" />
|
|
|
|
<a-table-column title="Tags" dataIndex="tags" key="tags">
|
2018-09-05 13:28:54 +00:00
|
|
|
<template slot-scope="tags">
|
|
|
|
<span>
|
|
|
|
<a-tag v-for="tag in tags" color="blue" :key="tag">{{tag}}</a-tag>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</a-table-column>
|
2019-09-28 12:45:07 +00:00
|
|
|
<a-table-column title="Action" key="action">
|
2018-04-01 04:52:27 +00:00
|
|
|
<template slot-scope="text, record">
|
|
|
|
<span>
|
2018-09-05 13:28:54 +00:00
|
|
|
<a href="javascript:;">Action 一 {{record.firstName}}</a>
|
2018-04-01 04:52:27 +00:00
|
|
|
<a-divider type="vertical" />
|
2018-09-05 13:28:54 +00:00
|
|
|
<a href="javascript:;">Delete</a>
|
2018-04-01 04:52:27 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</a-table-column>
|
|
|
|
</a-table>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-09-28 12:45:07 +00:00
|
|
|
const data = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
firstName: 'John',
|
|
|
|
lastName: 'Brown',
|
|
|
|
age: 32,
|
|
|
|
address: 'New York No. 1 Lake Park',
|
|
|
|
tags: ['nice', 'developer'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
firstName: 'Jim',
|
|
|
|
lastName: 'Green',
|
|
|
|
age: 42,
|
|
|
|
address: 'London No. 1 Lake Park',
|
|
|
|
tags: ['loser'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
firstName: 'Joe',
|
|
|
|
lastName: 'Black',
|
|
|
|
age: 32,
|
|
|
|
address: 'Sidney No. 1 Lake Park',
|
|
|
|
tags: ['cool', 'teacher'],
|
|
|
|
},
|
|
|
|
];
|
2018-04-01 04:52:27 +00:00
|
|
|
|
2019-09-28 12:45:07 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
2018-04-01 04:52:27 +00:00
|
|
|
</script>
|
|
|
|
```
|