iview的table中Tooltip使用

这篇文章主要介绍了iview-admin中在table中使用Tooltip提示效果。

1. table中文字溢出隐藏,提示气泡展示所有信息

jLongText(item){
    item.render = (h, params)=>{
        // 处理文字,溢出用点代替
        let txt = params.row[params.column.key]
        let tableTxt = null
        if(txt){
            if(txt.length > item.longText){
                tableTxt = txt.substring(0, item.longText) + '.....'
            }else{
                tableTxt = txt
            }
        }
        
        return h('Tooltip', {
            props: {
                placement: 'top'
            }
        },[
            tableTxt,
            h('span', {slot: 'content', style: {whiteSpace: 'normal', wordBreak: 'break-all'}}, txt)
        ])
    }
    return item
},
// style是 必须的,否则无法换行显示

2. Tooltip 折行显示效果

{
    title: '状态监控',
    align: 'center',
    key: 'stat'
    render: (h, params) => {
        return h('Tooltip', {
            props: {
                placement: "right"
            }
        },[
            stat,
            [
                h('p', { slot: 'content'},'CPU:11.1%'),
                h('p', { slot: 'content'},'内存:5/12GB')
            ]
        ]);
    }
}
// 使用多个标签实现多行显示,而不是换行

3. 单独使用Tooltip实现折行效果

<!-- 注意 Tooltip 内的文本使用了 white-space: nowrap;,即不自动换行,如需展示很多内容并自动换行时,建议给内容 slot 增加样式 white-space: normal; -->
<Tooltip :disabled="!msg">
    <div slot="content" style="white-space:normal">{{msg}}</div>
    <Input v-model="msg" />
</Tooltip>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值