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',
                age: '耳机目录',
                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>

posted @   南风晚来晚相识  阅读(824)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2020-07-23 计算两个数的百分比,保留两位小数
点击右上角即可分享
微信分享提示