--- group: path: /packages/interactive --- # getMenuButtonBoundingClientRect [![npm](https://img.shields.io/npm/v/@uni/navigation-bar.svg)](https://www.npmjs.com/package/@uni/navigation-bar) 解获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。
## 支持 wechatMiniprogram bytedanceMicroApp baiduSmartProgram kuaiShouMiniProgram ## 安装 ```bash $ npm install @uni/navigation-bar --save ``` or ```bash $ npm install @uni/apis --save ``` ## 示例 ```javascript import { getMenuButtonBoundingClientRect } from '@uni/navigation-bar'; getMenuButtonBoundingClientRect(); ``` 你也可以从大包引入: ```js import { navigationBar } from '@uni/apis'; navigationBar.getMenuButtonBoundingClientRect(); ``` ## 方法 ### `getMenuButtonBoundingClientRect()` ### 返回值 | 属性 | 类型 | 描述 | | --- | --- | --- | | width | `number`  | 宽度,单位:px | | height | `number`  | 高度,单位:px | | top | `number`  | 上边界坐标,单位:px | | right | `number`  | 右边界坐标,单位:px | | bottom | `number`  | 下边界坐标,单位:px | | left | `number`  | 左边界坐标,单位:px | ### 不通用返回(由于破坏了一码多端的能力,不推荐使用) | 属性 | 类型 | 描述 | 支持 | | --- | --- | --- | ----| | errMsg | `string`  | | bytedanceMicroApp |
```jsx | inline /** * iframe: true */ import React from 'react'; export default () => ( ); ```
微信小程序
```jsx | inline import React from 'react'; export default class Home extends React.Component { componentDidMount() { document.querySelector('.__dumi-default-menu').style.background = '#fff'; if (location.search.split(/[?&]/).some(i => i === 'clear=1')) { document.querySelector('.__dumi-default-navbar').style.display = 'none'; document.querySelector('.__dumi-default-layout').classList = []; document.querySelector('.__dumi-default-menu').style.display = 'none'; document.querySelector('.__dumi-default-layout-toc').style.display = 'none'; document.querySelector('.__dumi-default-layout-content').querySelector('.markdown').querySelector('h1').style.marginTop = 0; parent.postMessage && parent.postMessage(parent.postMessage({ event: 'syncIframeHeight', height: document.querySelector('.__dumi-default-layout-content').offsetHeight }, '*')); } } render() { return null; } } ```