chore: 添加demo

This commit is contained in:
dap 2024-08-08 16:28:23 +08:00
parent bb04bb0961
commit 01379f0c97
2 changed files with 104 additions and 0 deletions

View File

@ -16,6 +16,8 @@ import { DictTag } from '#/components/Dict';
import { useDictStore } from '#/store/dict'; import { useDictStore } from '#/store/dict';
import { getDict, getDictOptions } from '#/utils/dict'; import { getDict, getDictOptions } from '#/utils/dict';
import TableTest from './table';
onMounted(() => { onMounted(() => {
console.log('keepAlive测试 -> 挂载了'); console.log('keepAlive测试 -> 挂载了');
}); });
@ -93,5 +95,8 @@ onMounted(() => {
<ATag :bordered="false" color="geekblue">geekblue</ATag> <ATag :bordered="false" color="geekblue">geekblue</ATag>
<ATag :bordered="false" color="purple">purple</ATag> <ATag :bordered="false" color="purple">purple</ATag>
</Card> </Card>
<Card title="table测试">
<TableTest />
</Card>
</div> </div>
</template> </template>

View File

@ -0,0 +1,99 @@
import type { ColumnsType } from 'ant-design-vue/es/table';
import { defineComponent, ref } from 'vue';
import {
Button,
message,
Modal,
Popconfirm,
Space,
Table,
} from 'ant-design-vue';
export default defineComponent({
name: 'TableTest',
setup() {
const dataSource = [
{ age: 20, id: 1, name: '张三' },
{ age: 21, id: 2, name: '李四' },
{ age: 22, id: 3, name: '王五' },
];
const columns: ColumnsType = [
{
align: 'center',
dataIndex: 'id',
title: 'id',
},
{
align: 'center',
dataIndex: 'name',
title: '姓名',
},
{
align: 'center',
dataIndex: 'age',
title: '年龄',
},
{
align: 'center',
key: 'action',
title: '操作',
},
];
const open = ref(false);
return () => (
<div>
<Table
columns={columns}
dataSource={dataSource}
rowKey={'id'}
rowSelection={{ type: 'radio' }}
size={'middle'}
>
{{
bodyCell: ({ column }: { column: any }) => {
if (column.key === 'action') {
return (
<Space>
<Button
onClick={() => {
open.value = true;
}}
size="small"
type="primary"
>
</Button>
<Popconfirm
onConfirm={() => {
message.success('删除成功');
}}
placement="left"
title={'确认删除该条记录?'}
>
<Button danger size="small" type="primary">
</Button>
</Popconfirm>
</Space>
);
}
},
}}
</Table>
<Modal
footer={null}
onCancel={() => (open.value = false)}
open={open.value}
title={'modal'}
>
<p></p>
</Modal>
</div>
);
},
});