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


<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

          });

        }

      }

    })

  },

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。