HomeDocs
Skip to main content

SelectorQuery

Introduction

Selector.

Method Parameters

MethodParametersDescription
execNoneExecutes all the requests.
selectselectorSelects the first node that matches the selector selector in the current page and returns a NodesRef object instance that can be used to retrieve node information.
selectAllselectorSelects nodes that match the selector selector in the current page and returns a NodesRef object instance. Unlike selectorQuery.select(selector), this selects all nodes that match the selector.
selectViewportNoneSelects the display area and can be used to obtain information such as the size and scroll position of the display area. Returns a NodesRef object instance.

Sample Code

Page({
onReady() {
this.selectorQuery = dlt.createSelectorQuery();
},
queryNodeInfo() {
this.selectorQuery
// .in(this); Use this statement for custom components
.select('.target')
// Or .selectAll('.target')
// Or .selectViewport()
.boundingClientRect((res) => {
console.log('Node Information', res);
})
.exec();
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.