小程序开放平台

文档中心
基础
转发
界面
交互
菜单
getMenuButtonBoundingClientRect
网络
数据缓存
渲染
媒体
文件
开放接口
设备
跳转
位置
支付

xhs.getMenuButtonBoundingClientRect

开发
>
JS API
>
界面
>
菜单
>
getMenuButtonBoundingClientRect
>
更新时间:2024-11-14 11:47:47

以Promise风格调用: 不支持。

获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。

返回值

Object res

属性
类型
说明
widthnumber宽度,单位:px
heightnumber高度,单位:px
topnumber上边界坐标,单位:px
rightnumber右边界坐标,单位:px
bottomnumber下边界坐标,单位:px
leftnumber左边界坐标,单位:px

示例代码

const res = xhs.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)
该文档是否对您有帮助?