字段长度限制,超出省略 悬浮显示全部

代码:

   <template slot="note" slot-scope="text,record">
        <a-popover>
             <template #content> {{ text }} </template>
             <div>{{ record.note | fieldLength }}</div>
        </a-popover>
   </template>

 

//过滤
  filters: {
     fieldLength(value) {
         if (!value) return '';
         if (value.length > 10) {
              return value.slice(0, 10) + '...'
         }
            return value
        }
    }

 

效果:

 (正常显示,超出10个字省略)     (悬浮显示全部)

 

posted @ 2022-08-04 14:21  小兔儿_乖乖  阅读(121)  评论(0)    收藏  举报