<view class='content'>
<view class='c_text' id="box" style='-webkit-line-clamp:{{lineclamp}}'>
本酒店好霸道个地方不化的风格股的方法反反复复部分 地方改变地方vadfvdfjfbiiiuioulkdaflgvbdfgbvf 胡椒粉IDGV不vbfudioshbdfb电饭锅电饭锅电饭锅 大风过后如果喝好中发现不对覅后在低V胡答复VB 胡椒粉IDGV不vbfudioshbdfb电饭锅电饭锅电饭锅 大风过后如果喝好中发现不对覅后在低V胡答复VB
</view>
<view class='appear' hidden='{{status==0}}'>
<button type='primary' bindtap='isclick' hover-class='none'>显示全部</button>
</view>
</view>
.content{
padding: 20rpx;
}
.c_text{
font-size: 32rpx;
display: -webkit-box;
text-overflow:ellipsis;
overflow: hidden;
word-break: break-all;
white-space: pre-line;
-webkit-box-orient: vertical;
/*-webkit-line-clamp:2;*/
text-indent:2em;
color: #515151;
}
.appear{
margin-top: 20rpx;
border-top: 1px solid #ddd;
}
.appear button{
margin:30rpx auto;
width:30%;
font-size: 30rpx;
background:transparent;
color:#999;
}
data: {
lineclamp:6,
},
boxheight(e){
var that=this;
var query = wx.createSelectorQuery();
query.select('#box').boundingClientRect()
query.exec(function (res) {
console.log(res[0].height);
var boxheight = res[0].height;
if (boxheight<140){
var status=0;
}
that.setData({
boxheight: boxheight,
status: status
})
})
},
isclick(){
this.setData({
lineclamp:1000,
status:0
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.boxheight();
},
类似这种,样子很丑,很久很久之前测试写的,一直没用上,有好的方法,欢迎指正啊