微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ant Design Vue中Table对齐方式显示省略号

Ant Design Vue中Table对齐方式显示省略号

<template>
    <!-- bordered 表示表格中的边框
     pagination="false"不要分页 
	-->
	 
    <a-table :data-source="dataSource" :columns="columns" :pagination="false">
        <template #operation="{ record }">
            <a class="">编辑</a>
            <a class="line-linela"></a>
            <a-popconfirm
                v-if="dataSource.length"
                title="Sure to delete?"
                @confirm="onDelete(record.key)"
            >
                <a>删除</a>
            </a-popconfirm>
        </template>
    </a-table>
</template>
<script lang="ts">
import { defineComponent,Ref,ref } from 'vue'

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

export default defineComponent({
    setup() {
        // 字段(也就是表头)
        const columns = [
            {
                title: '编号',//字段名称
                dataIndex: 'fileNmae',width: '30%',},{
                title: '名称',dataIndex: 'fileNmae',{
                title: '备注',dataIndex: 'address',ellipsis: true,//超出显示省略好
            },{
                title: '操作',dataIndex: 'operation',slots: { customrender: 'operation' },align: 'right',//左对齐
            },]
        // 表中的数据
        const dataSource: Ref<DataItem[]> = ref([
            {
                key: '0',fileNmae: 'ML2340124',age: '耳机目录',address: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',{
                key: '1',fileNmae: 'Edward King 1',address: 'London,Park Lane no. 1',])

        const onDelete = (key: string) => {
            console.log('==>',dataSource)
            dataSource.value = dataSource.value.filter(item => item.key !== key)
        }

        return {
            columns,onDelete,dataSource,}
    },})
</script>
<style lang="less">
.line-linela {
    width: 1px;
    height: 13px;
    display: inline-block;
    background: #f0f0f0 !important;
    margin-left: 8px;
    margin-right: 9px;
}
</style>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐