mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-04 20:27:44 +08:00
49 lines
1.0 KiB
Vue
49 lines
1.0 KiB
Vue
<template>
|
|
<el-table
|
|
:data="tableData"
|
|
:default-sort="{ prop: 'date', order: 'descending' }"
|
|
style="width: 100%"
|
|
>
|
|
<el-table-column prop="date" label="Date" sortable width="180" />
|
|
<el-table-column prop="name" label="Name" width="180" />
|
|
<el-table-column prop="address" label="Address" :formatter="formatter" />
|
|
</el-table>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import type { TableColumnCtx } from 'element-plus'
|
|
|
|
interface User {
|
|
date: string
|
|
name: string
|
|
address: string
|
|
}
|
|
|
|
const formatter = (row: User, column: TableColumnCtx<User>) => {
|
|
return row.address
|
|
}
|
|
|
|
const tableData: User[] = [
|
|
{
|
|
date: '2016-05-03',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
date: '2016-05-02',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
date: '2016-05-04',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
date: '2016-05-01',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
]
|
|
</script>
|