微信小程序获取菜单按钮(右上角胶囊按钮)的布局位置信息,可以使用Object wx.getMenuButtonBoundingClientRect()接口,坐标信息以屏幕左上角为原点。
示例代码:
const res = wx.getMenuButtonBoundingClientRect()
console.log(res.width)
console.log(res.height)
console.log(res.top)
console.log(res.right)
console.log(res.bottom)
console.log(res.left)
菜单按钮的布局位置信息
width宽度
height高度
top上边界坐标
right右边界坐标
bottom下边界坐标
left左边界坐标
上面参数的单位均为:px
暂无评论,抢个沙发...