render函数添加title属性控制文字长度

render: (h, params) => {
     let _this = this
     return h('div',[
     h('div',{
      class:'text-overflow-ellipsis',//用类名控制文字溢出显示省略号
      attrs:{
         title:'这是超出要显示的文字',
      },
      props: {
      type: "text",
      size: "small",
      },
     ,params.row.isEdit?'内容':'文字内容')
    ])
}

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
首先,你需要在 Vue3 项目中安装 Ant Design Vue 组件库,在你的组件中引入 `a-table` 组件,具体的代码如下: ```vue <template> <div> <a-table :columns="columns" :data-source="dataSource"> <template #action="{ record }"> <a-button @click="deleteRow(record.key)" type="danger">删除</a-button> </template> </a-table> <a-button @click="addRow" type="primary" style="margin-top: 16px">添加行</a-button> </div> </template> <script> import { ref } from 'vue'; import { Button, Table } from 'ant-design-vue'; export default { components: { 'a-button': Button, 'a-table': Table, }, setup() { const dataSource = ref([ { key: 1, name: 'John Brown', age: 32, address: 'New York No. 1 Lake Park', }, { key: 2, name: 'Jim Green', age: 42, address: 'London No. 1 Lake Park', }, { key: 3, name: 'Joe Black', age: 32, address: 'Sidney No. 1 Lake Park', }, ]); const columns = ref([ { title: '姓名', dataIndex: 'name', key: 'name', }, { title: '年龄', dataIndex: 'age', key: 'age', }, { title: '地址', dataIndex: 'address', key: 'address', }, { title: '操作', key: 'action', slots: { customRender: 'action' }, }, ]); const addRow = () => { dataSource.value.push({ key: dataSource.value.length + 1, name: '', age: '', address: '', }); }; const deleteRow = (key) => { dataSource.value = dataSource.value.filter((item) => item.key !== key); }; return { dataSource, columns, addRow, deleteRow, }; }, }; </script> ``` 在这段代码中,我们使用了 `ref` 函数来创建响应式数据 `dataSource` 和 `columns`,并且使用了 `a-table` 组件来展示表格数据。我们还添加了一个按钮 `添加行`,并且在 `setup` 函数中定义了 `addRow` 和 `deleteRow` 函数来处理增删操作。 在 `addRow` 函数中,我们使用 `push` 方法向 `dataSource` 中添加一条新的数据,其中 `key` 属性为当前数据长度加 1,其他属性为空字符串。 在 `deleteRow` 函数中,我们使用 `filter` 方法来过滤掉 `key` 属性等于传入参数 `key` 的数据项。 同时,我们还使用了 `slots` 来自定义 `action` 列的渲染方式,使得每一行的最后一列都显示一个删除按钮。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值