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

简介: 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>


1425695-20210723150123951-291887015.png

相关文章
|
18天前
|
JavaScript 前端开发 开发者
vue3+ts配置跨域报错问题解决:> newpro2@0.1.0 serve > vue-cli-service serve ERROR Invalid options in vue.
【6月更文挑战第3天】在 Vue CLI 项目中遇到 &quot;ERROR Invalid options in vue.config.js: ‘server’ is not allowed&quot; 错误是因为尝试在 `vue.config.js` 中使用不被支持的 `server` 选项。正确配置开发服务器(如代理)应使用 `devServer` 对象,例如设置代理到 `http://xxx.com/`: ```javascript module.exports = { devServer: {
30 1
|
4天前
|
前端开发 JavaScript
Vue底层实现原理总结
Vue底层实现原理总结
8 0
|
8天前
|
JavaScript 前端开发 测试技术
使用 Vue CLI 脚手架生成 Vue 项目
通过 Vue CLI 创建 Vue 项目可以极大地提高开发效率。它不仅提供了一整套标准化的项目结构,还集成了常用的开发工具和配置,使得开发者可以专注于业务逻辑的实现,而不需要花费大量时间在项目配置上。
67 7
使用 Vue CLI 脚手架生成 Vue 项目
|
6天前
|
JavaScript
|
7天前
|
存储 JavaScript API
Vue状态管理深度剖析:Vuex vs Pinia —— 从原理到实践的全面对比
Vue状态管理深度剖析:Vuex vs Pinia —— 从原理到实践的全面对比
13 2
|
10天前
|
JavaScript 算法
“Error: error:0308010C:digital envelope routines::unsupported”启动vue项目遇到一个错误【已解决
“Error: error:0308010C:digital envelope routines::unsupported”启动vue项目遇到一个错误【已解决
11 1
|
10天前
|
JavaScript
error Component name “Login“ should always be multi-word vue/multi-word-component-names【已解决】
error Component name “Login“ should always be multi-word vue/multi-word-component-names【已解决】
25 1
|
11天前
|
JavaScript API
【vue实战项目】通用管理系统:信息列表,信息录入
【vue实战项目】通用管理系统:信息列表,信息录入
19 3
|
11天前
|
JavaScript API
【vue实战项目】通用管理系统:信息列表,信息的编辑和删除
【vue实战项目】通用管理系统:信息列表,信息的编辑和删除
26 2
|
11天前
|
JavaScript 前端开发 API
【vue实战项目】通用管理系统:学生列表
【vue实战项目】通用管理系统:学生列表
40 2