天天看点

css 判断文字有没有溢出项目场景:解决方案:

项目场景:

 文字溢出要给个提示显示查看更多

解决方案:

<p class="topic-desc gey-text-color-light" id="desc">
  简介:{{dataSource.fdIntroduction ? dataSource.fdIntroduction : '暂无'}}
</p>      
data () {
  return {
    showMore: false
  }
},      
let width = document.getElementById('desc')
if (width.scrollHeight > width.offsetHeight) {
  this.showMore = true
} else {
  this.showMore = false
}