mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-05 04:37:47 +08:00
132 lines
2.6 KiB
Vue
132 lines
2.6 KiB
Vue
<template>
|
|
<div>
|
|
<el-table
|
|
:data="tableData"
|
|
style="width: 100%; margin-bottom: 20px"
|
|
row-key="id"
|
|
border
|
|
default-expand-all
|
|
>
|
|
<el-table-column prop="date" label="Date" sortable />
|
|
<el-table-column prop="name" label="Name" sortable />
|
|
<el-table-column prop="address" label="Address" sortable />
|
|
</el-table>
|
|
|
|
<el-table
|
|
:data="tableData1"
|
|
style="width: 100%"
|
|
row-key="id"
|
|
border
|
|
lazy
|
|
:load="load"
|
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
|
>
|
|
<el-table-column prop="date" label="Date" />
|
|
<el-table-column prop="name" label="Name" />
|
|
<el-table-column prop="address" label="Address" />
|
|
</el-table>
|
|
</div>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
interface User {
|
|
id: number
|
|
date: string
|
|
name: string
|
|
address: string
|
|
hasChildren?: boolean
|
|
children?: User[]
|
|
}
|
|
|
|
const load = (
|
|
row: User,
|
|
treeNode: unknown,
|
|
resolve: (date: User[]) => void
|
|
) => {
|
|
setTimeout(() => {
|
|
resolve([
|
|
{
|
|
id: 31,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 32,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
])
|
|
}, 1000)
|
|
}
|
|
|
|
const tableData: User[] = [
|
|
{
|
|
id: 1,
|
|
date: '2016-05-02',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 2,
|
|
date: '2016-05-04',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 3,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
children: [
|
|
{
|
|
id: 31,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 32,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: 4,
|
|
date: '2016-05-03',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
]
|
|
|
|
const tableData1: User[] = [
|
|
{
|
|
id: 1,
|
|
date: '2016-05-02',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 2,
|
|
date: '2016-05-04',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 3,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
hasChildren: true,
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 4,
|
|
date: '2016-05-03',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
]
|
|
</script>
|