WeChat アプレットのカスタム コンポーネントは、wx.createSelectorQuery() を使用してノードの問題を取得します

1:ライフサイクルの準備完了フェーズで取得する必要がある
。 2: wx.createSelectorQuery() の後に in() を使用して範囲を指定する必要がある。

Component({
    properties(){

    },
    data(){

    },
    methods(){

    },
    lifetimes: {
       ready: function (){
          wx.createSelectorQuery().in(this).select('.canvas').boundingClientRect(function (rect) {
          console.log(rect)
         }).exec()
      }
})


おすすめ

転載: blog.csdn.net/qq_29483485/article/details/126429342