HomeDocs
跳到主要内容

SelectorQuery.exec

简介

执行所有的请求,请求结果按请求次序构成数组,在 callback 的第一个参数中返回。

入参

Function callback

示例代码

Page({
data: {
metrics: [],
},
onReady() {
this.queryNodeInfo();
},
queryNodeInfo() {
const query = dlt.createSelectorQuery();
query.select('.target').boundingClientRect((rect) => {
console.log('节点信息:', rect);
if (rect) {
const metrics = [];
for (const key in rect) {
if (key !== 'id' && key !== 'dataset') {
const val = rect[key];
metrics.push({ key, val });
}
}
this.setData({ metrics });
}
});
query.exec();
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.