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

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

作者: 高小花大花 | 来源:发表于2020-08-19 16:39 被阅读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

          });

        }

      }

    })

  },

相关文章

网友评论

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

      本文链接:https://www.haomeiwen.com/subject/qogzxqtx.html