微信小程序获取某个元素的宽度和高度

  onReady: function () {
    let query = wx.createSelectorQuery();
    let that = this;
    query.select('#header').boundingClientRect(function (rect) {
      that.setData({
        height: rect.height + 'px',
        width: rect.width + 'px'
      })
    }).exec();
   
  }
发布了125 篇原创文章 · 获赞 3 · 访问量 5872

猜你喜欢

转载自blog.csdn.net/z591102/article/details/105117837