2018-11-10小程序 文字点击收起展示 循环
![](https://img.haomeiwen.com/i14903912/30dd72a14eb88301.jpg)
![](https://img.haomeiwen.com/i14903912/610bfe55e7f77e88.jpg)
<view class="txtshow" wx:for="{{list}}">
<view id="frame{{index}}" class="cyytxt {{item.isShow ? 'nofold':''}}">
<text id="content{{index}}">{{item.txt}}</text></view>
<image src="{{item.isShow?'/images/up_arrow.png':'/images/Down_arrow.png'}}" class="sq" bindtap="click" data-id="{{index}}"></image>
</view>
click:function(e){
var query = wx.createSelectorQuery();
let that = this
var index=e.currentTarget.dataset.id
let currect = "list["+index+"].isShow"
query.select('#content'+index).boundingClientRect();
query.select('#frame'+index).boundingClientRect();
query.exec(function (res) {
if (res[0] && res[0].height) {
if (res[0].height > res[1].height) {
that.setData({
[currect]: true
});
} else {
that.setData({
[currect]: false
});
}
}
})
},