微信小程序右上角胶囊的位置

参考:https://www.cnblogs.com/luoshida/p/13434197.html

右上角胶囊的信息,包含width、height、top等
let rect= wx.getMenuButtonBoundingClientRect();
 
机型信息
let info=wx.getSystemInfoSync();
 
胶囊底部到手机最上面的距离
rect.bottom
 
胶囊三个点到屏幕右边的距离,这个需要赋值给right,即right等于以下

this.setData({
left: wx.getMenuButtonBoundingClientRect().left + wx.getMenuButtonBoundingClientRect().width / 3
})
 
 

原文地址:https://www.cnblogs.com/lude1994/p/15041681.html