提交 | 用户 | age
|
faf3f4
|
1 |
<template> |
陈 |
2 |
<div class="p-4"> |
|
3 |
<BasicTable @register="registerTable"> |
|
4 |
<template #id="{ record }"> ID: {{ record.id }} </template> |
|
5 |
<template #no="{ record }" |
|
6 |
><Tag color="green">{{ record.no }}</Tag> |
|
7 |
</template> |
|
8 |
<template #img> |
|
9 |
<TableImg |
|
10 |
:imgList="['https://picsum.photos/id/66/346/216', 'https://picsum.photos/id/67/346/216']" |
|
11 |
/> |
|
12 |
</template> |
|
13 |
</BasicTable> |
|
14 |
</div> |
|
15 |
</template> |
|
16 |
<script lang="ts"> |
|
17 |
import { defineComponent } from 'vue'; |
|
18 |
import { BasicTable, useTable, BasicColumn, TableImg } from '/@/components/Table'; |
|
19 |
import { Tag } from 'ant-design-vue'; |
|
20 |
import { demoListApi } from '/@/api/demo/table'; |
|
21 |
const columns: BasicColumn[] = [ |
|
22 |
{ |
|
23 |
title: 'ID', |
|
24 |
dataIndex: 'id', |
|
25 |
slots: { customRender: 'id' }, |
|
26 |
}, |
|
27 |
{ |
|
28 |
title: '姓名', |
|
29 |
dataIndex: 'name', |
|
30 |
width: 120, |
|
31 |
}, |
|
32 |
{ |
|
33 |
title: '头像', |
|
34 |
dataIndex: 'img', |
|
35 |
width: 120, |
|
36 |
slots: { customRender: 'img' }, |
|
37 |
}, |
|
38 |
{ |
|
39 |
title: '地址', |
|
40 |
dataIndex: 'address', |
|
41 |
}, |
|
42 |
{ |
|
43 |
title: '编号', |
|
44 |
dataIndex: 'no', |
|
45 |
slots: { customRender: 'no' }, |
|
46 |
}, |
|
47 |
{ |
|
48 |
title: '开始时间', |
|
49 |
dataIndex: 'beginTime', |
|
50 |
}, |
|
51 |
{ |
|
52 |
title: '结束时间', |
|
53 |
dataIndex: 'endTime', |
|
54 |
}, |
|
55 |
]; |
|
56 |
export default defineComponent({ |
|
57 |
components: { BasicTable, TableImg, Tag }, |
|
58 |
setup() { |
|
59 |
const [registerTable] = useTable({ |
|
60 |
title: '自定义列内容', |
|
61 |
api: demoListApi, |
|
62 |
columns: columns, |
|
63 |
}); |
|
64 |
|
|
65 |
return { |
|
66 |
registerTable, |
|
67 |
}; |
|
68 |
}, |
|
69 |
}); |
|
70 |
</script> |