wx.createSeclectorQuert()中setData无效?
发布于 5 年前 作者 rshen 9194 次浏览 来自 问答
istextShrink(){
    var that=this;
    for(var j=0;j<that.data.loadvlog.length;j++){
      var textv='#textv'+j;
      var textshow='#textshow'+j;
      const query = wx.createSelectorQuery()                // 创建节点查询器 query
      query.select(textv).boundingClientRect()   
      query.select(textshow).boundingClientRect() 
            query.exec((res) => {   
        if(res[0]&&res[0].height){
          if(res[0].height>=res[1].height){
              that.setData({                 //这两个setData没有赋值,读出来是undifined
              flag:true
            })
          }
          else{
            that.setData({
              flag:false
            })
          }
      })
      that.setData({
        ['loadvlog.['+j+'].flag']:that.data.flag
      })
    }
  },
回到顶部