selectorquery.exec(function callback)
支小宝客户端 支持
安诊儿客户端 支持
主体: 企业支付宝小程序 、 个人支付宝小程序
执行所有的请求。
exec 必须在页面渲染完成后调用。页面渲染完成的时机有:
- 在 page.onready 中。注意:page.onready 只会在页面初次渲染完成时触发。
- 在 page.onshow 中。
- 在 setdata 回调函数中。
function callback
回调函数。请求结果按请求次序构成数组,数组中每项为一次查询的结果。
参数
array res
查看示例
selectorquery.exec(function callback)
.axml
.js
callback 参数
<view class="page">
<view class="page-section">
<view class="all">节点 all1view>
<view class="all">节点 all2view>
<view id="one">节点 oneview>
<button type="primary" ontap="oncreateselectorquery">节点查询button>
view>
view>
page({
oncreateselectorquery() {
my.createselectorquery()
.select(".nonexist").boundingclientrect()
.select('#one').boundingclientrect()
.selectall('.all').boundingclientrect()
.exec((res) => {
console.log(res);
})
}
})
[
null,
{
"id": "one",
"dataset": {},
"left": 0,
"right": 390,
"top": 57.5859375,
"bottom": 76.78125,
"width": 390,
"height": 19.1953125
},
[
{
"id": "",
"dataset": {},
"left": 0,
"right": 390,
"top": 19.1953125,
"bottom": 38.390625,
"width": 390,
"height": 19.1953125
},
{
"id": "",
"dataset": {},
"left": 0,
"right": 390,
"top": 38.390625,
"bottom": 57.5859375,
"width": 390,
"height": 19.1953125
}
],
{
"id": "",
"dataset": {},
"scrollleft": 0,
"scrolltop": 0,
"scrollwidth": 390,
"scrollheight": 754
}
]