超过两行...,只有两行或少于两行无...且没有查看更多文字 关键思路:超过两行...用ellipsis,可是为了判断文字是否多余两行,因此要获取节点的高度,若是大于两行则文字出现,不然没有更多文字

关键代码:css

This.dataList = this.dataList.map((item,index)=>{web

Let showFlag = this.$refs.textContent[index].offsetHeight > 44 ? true : falsethis

If(this.$refs.textContent[index].offsetHeight > 44){spa

This.$refs.textContent[index].style.overflow = ‘hidden’ip

This.$refs.textContent[index].style.textOverflow = ‘ellipsis’it

This.$refs.textContent[index].style.display = ‘-webkit-box’cli

}List

})webkit

 

//由于原生的style中没有属性-webkit-line-clamp: 2; -webkit-box-orient: vertical;map

因此直接写在css中,最后要切样式 overflow: auto; text-overflow: clip; display: block;-webkit-line-clamp: none; -webkit-box-orient: inherit; line-height: 22px;

相关文章
相关标签/搜索