HomeDocs
Skip to main content

NodesRef.boundingClientRect

Introduction

Adds a query request for the layout position of a node relative to the display area (unit: pixels). It functions similarly to getBoundingClientRect in the DOM. The return value is the selectorQuery corresponding to the nodesRef.

Parameters

Function callback

Explanation of callback return parameters

In the returned node information, the position of each node is described by the fields left, right, top, bottom, width, and height. If a callback function is provided, after executing the exec method of selectQuery, the node information will be returned in the callback.

ParameterTypeDescription
leftNumberNode's left boundary coordinate
rightNumberNode's right boundary coordinate
topNumberNode's top boundary coordinate
bottomNumberNode's bottom boundary coordinate
widthNumberNode's width
heightNumberNode's height

Sample Code

Page({
queryNodeInfo() {
dlt
.createSelectorQuery()
.select('.target')
.boundingClientRect((rect) => {
console.log('Node Information', rect);
})
.exec();
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.