背景
在網上看到很多這樣的,有很多這樣的例子。
https://gitee.com/dggy/expendable/tree/master
比如上面這個大哥就是用的非常好的,但是有點冗餘
在來看看這個,下面是效果圖,可以參考下面的連接
https://www.jb51.net/article/141882.htm
實際方案
需要一個簡單的,默認顯示問題是一部分,點擊後,顯示的是全部的內容。再次點擊回覆到默認即可。
下面是部分代碼
// js
isHide: true,
showMoreMsg: function() { //點擊顯示全部內容
this.setData ({
isHide: !this.data.isHide
})
},
// wxml
<view class="{{isHide?'hide':'show'}}" bindtap="showMoreMsg">{{item.content}}</view>
// wxss
.hide {
margin-top: 15rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.show {
margin-top: 15rpx;
overflow: hidden;
text-overflow: ellipsis;
}