1. 程式人生 > >#小程式#獲得螢幕高度,view高度

#小程式#獲得螢幕高度,view高度

wxml中:<view id='getheight'></view>

var query = wx.createSelectorQuery();
query.select('#getheight').boundingClientRect()
query.exec(function (res) {
  //console.log(res);
  console.log(res[0].height);
})

手機螢幕高度單位rpx:

 wx.getSystemInfo({
      success: function(res) {
        let h = 750 * res.windowHeight/res.windowWidth
         console.log(h);
      }
    })