小程序获取节点数据

话不多说上代码

  wx.createSelectorQuery().select('.class').fields({
      dataset: true,
      size: true,
      scrollOffset: true,
      properties: ['scrollX', 'scrollY']
    }, function (res) {
      console.log(res)
    }).exec() 

粘贴过去就能用,前提是那个  .class 换成自己需要的class (注意不要使用页面元素去找,最好使用class名称,或id名称

我就是遇到这个坑,我用元素就是不行,比如使用text 。

这个我分析是小程序类似于vue 这玩意不能像html的js那样用

参考链接 https://www.hishop.com.cn/xiaocx/show_47372.html

个人笔记转载请注明出处

原文地址:https://www.cnblogs.com/hkzw/p/13598148.html