---
name: "SelectorQuery.exec"
mode: "api"
versionRequirements:
  - { name: "基础库", version: "2.10.0" }
title: "SelectorQuery.exec - 执行所有的请求"
---

## SelectorQuery.exec

> [VERSION] 基础库 >= 2.10.0

### 描述

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

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `execCallback` | `unknown` | 是 | 执行完成回调，参数为查询结果数组 |

### 返回值

无


### 示例代码

#### 批量查询并执行

```html
// index.tyml
<view id="header" class="header">头部</view>
<view class="content">内容区域</view>
<view id="footer" class="footer">底部</view>
```

```js
// index.js
Page({
  onReady() {
    var query = ty.createSelectorQuery();
    query.select('#header').boundingClientRect();
    query.select('#footer').boundingClientRect();
    query.exec((results) => {
      var header = results[0];
      var footer = results[1];
      console.log('头部高度', header.height);
      console.log('底部高度', footer.height);
    });
  },
});
```

```css
// index.tyss
.header, .footer {
  height: 100rpx;
  background-color: #e8f4ff;
  text-align: center;
  line-height: 100rpx;
}
.content {
  height: 400rpx;
  background-color: #f5f5f5;
}
```
