12

<template>
    <a-table :columns="columns" :data-source="data">
        <template #action>
            <a>action</a>
        </template>
    </a-table>
</template>
<script lang="ts">
import { defineComponent } from 'vue'

const columns = [
    {
        title: 'Age',
        dataIndex: 'age',
        key: 'age',
        // 字符串类型的数据 2021-12-15 12:12:12是无法排序的
        sorter: (a, b) => parseInt(a.age) - parseInt(b.age),
    },
    { title: 'Column 1', dataIndex: 'address', key: '1' },
    { title: 'Column 2', dataIndex: 'address', key: '2' },
]

interface DataItem {
    key: string
    name: string
    age: string
    address: string
}

const data: DataItem[] = [
    {
        key: '1',
        name: 'John Brown',
        age: '2020-12-15 12:12:12',
        address: 'New York Park',
    },
    {
        key: '2',
        name: 'Jim Green',
        age: '2021-12-15 12:12:12',
        address: 'London Park',
    },
]

export default defineComponent({
    data() {
        return {
            data,
            columns,
        }
    },
})
</script>
posted @ 2021-08-24 19:21  南风晚来晚相识  阅读(22)  评论(0编辑  收藏  举报