SelectorQuery
Introduction
Selector.
Method Parameters
Method | Parameters | Description |
---|---|---|
exec | None | Executes all the requests. |
select | selector | Selects 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. |
selectAll | selector | Selects 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. |
selectViewport | None | Selects 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();
},
});