2018-11-10小程序 文字点击收起展示 循环

2020-08-19  本文已影响0人  高小花大花

<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

          });

        }

      }

    })

  },

上一篇 下一篇

猜你喜欢

热点阅读