dlt.getMenuButtonBoundingClientRect
Introduction
Get the layout information of the menu button (the capsule button in the upper right corner). The coordinate information is based on the upper left corner of the screen.
Usage Limitations
Supported in the base library version 4.0.0 or higher.
Parameters
Object object
Property | Type | Default | Required | Description |
---|---|---|---|---|
success | function | No | The callback function for a successful API call. | |
fail | function | No | The callback function for a failed API call. | |
complete | function | No | The callback function that is called when the API call ends (whether it succeeds or fails). |
object.success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | string | true - Success |
width | number | Width in pixels |
height | number | Height in pixels |
top | number | Top coordinate in pixels |
right | number | Right coordinate in pixels |
bottom | number | Bottom coordinate in pixels |
left | number | Left coordinate in pixels |
object.fail Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | string | false - Failure |
Sample Code
// pages/index/index.js
Page({
getMenuButtonBoundingClientRect() {
dlt.getMenuButtonBoundingClientRect({
success: () => {
console.log('success');
},
});
},
});
In the sample code provided, dlt.getMenuButtonBoundingClientRect
is used to retrieve the layout information of the menu button. When the operation is successful, the success callback function is called, and it logs "success" to the console. The layout information includes the width, height, and coordinates (top, right, bottom, left) of the menu button in pixels.