iview表格内容,设置省略后如何显示title(鼠标滑过显示文本)

我在定义表格内容时,使用了ellipsis关键词,使文字溢出后显示省略号,这个时候如何实现鼠标移入显示全部文字呢?title不知道加在哪里。(css能实现的话我都不犯愁的。。。)
部分表格内容配置

  {
    title: '创建人',
    key: 'creatorName',
    ellipsis: true,
    width: '60',
    align: 'center'
  },
  
  

————————————————————————————————————
感谢这位兄台提供render函数思路~

顺便问一下,在render函数里写的点击事件,如何防止冒泡?
标签中直接@click.prevent.stop=""就可以了,那么render呢?
附上代码

{
    title: '操作',
    width: '70',
    align: 'center',
    render: (h, params) => {
      return h('a', {
        on: {
          click: () => {
            this.removeItemContent(params.row.id);
          }
        }
      }, '移除');
    }
  },

阅读 9.1k
1 个回答

使用render函数

{
    title: '创建人',
    key: 'creatorName',
    width: '60',
    align: 'center',
    render: (h, params) => {
      return h('div', [
         h('span', {
             style: {
                 display: 'inline-block',
                 width: '100%',
                 overflow: 'hidden',
                 textOverflow: 'ellipsis',
                 whiteSpace: 'nowrap'
             },
             domProps: {
                 title: params.row.creatorName
             }
         }, params.row.creatorName)
     ]);
         
   }
}

至于冒泡的话,直接原生JS就可以了;

on: {
    click: (e) => {
        e.stopPropagation();
        this.removeItemContent(params.row.id);
    }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题