文字超出 省略号显示 并显示提示框!

 

 

//目的: 该方法调用会将新闻数组的每一项中添加“isOverflow”字段 (true为内容过长)  每次取请求数据改变都要调用该方法

//参数:news  是你需要检测的元素 (也就是上图的acceptValueList)

isShowTextContent(news){

  this.$nextTick(function(){

    this.$refs[news].forEach((item,index)=>{

      let cWidth = this.$refs[news][index].clientWidth

      let sWidth = this.$refs[news][index].scrollWidth

      if(sWidth>cWidth){

        this.$set(this.[news][index],"isOverflow",true)
      }else{

        this.$set(this.[news][index],"isOverflow",false)
      }
    })

  })

}

 

 

posted @ 2019-12-26 10:22  一个前端码畜  阅读(738)  评论(0编辑  收藏  举报