Skip to content

Commit 91d0584

Browse files
authored
Merge pull request #2270 from didi/docs-ref-info
doc: 修改createSelectorQuery文档
2 parents 924d1d8 + 29141d0 commit 91d0584

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

  • docs-vitepress/guide/platform

docs-vitepress/guide/platform/rn.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,14 +1435,14 @@ Mpx 完全支持自定义组件功能,组件创建、属性配置、生命周
14351435
| id, dataset | ✅ 完全支持 | 节点基础属性 |
14361436
| setData | ✅ 完全支持 | 数据更新方法 |
14371437
| triggerEvent | ✅ 完全支持 | 事件触发 |
1438-
| selectComponent | ✅ 有限制 | 选择子组件,仅支持 id/class 选择器,需配合 `wx:ref` 使用 |
1439-
| selectAllComponents | ✅ 有限制 | 选择所有子组件,仅支持 id/class 选择器,需配合 `wx:ref` 使用 |
1438+
| createSelectorQuery | ✅ 有限制 | 返回一个 SelectorQuery 对象实例,用以查询基础节点位置等属性,需配合 `wx:ref` 使用 |
1439+
| selectComponent | ✅ 有限制 | 在父组件当中获取子组件的实例对象,返回匹配到的第一个组件实例,需配合 `wx:ref` 使用 |
1440+
| selectAllComponents | ✅ 有限制 | 在父组件当中获取子组件的实例对象,返回匹配到的全部组件实例对象组成的数组,需配合 `wx:ref` 使用 |
14401441
| $set, $watch, $delete | ✅ 完全支持 | 响应式数据操作 |
14411442
| $refs, $forceUpdate, $nextTick | ✅ 完全支持 | 组件实例方法 |
14421443
| $rawOptions | ✅ 完全支持 | 原始选项访问 |
14431444
| $i18n | ✅ 完全支持 | 国际化访问器 |
14441445
| is | ✅ 完全支持 | 动态组件 |
1445-
| createSelectorQuery | ❌ 不支持 | 节点查询 |
14461446

14471447
**🔧 selectComponent / selectAllComponents 使用要点**
14481448

@@ -1470,7 +1470,30 @@ Mpx 完全支持自定义组件功能,组件创建、属性配置、生命周
14701470
})
14711471
</script>
14721472
```
1473+
**🔧 createSelectorQuery 使用要点**
14731474

1475+
使用 `createSelectorQuery` 来获取基础组件需要在基础节点上标记 `wx:ref` 标签才能生效,以及所支持的选择器范围和 `selectComponent`/`selectAllComponents` 一致
1476+
1477+
```javascript
1478+
<template>
1479+
<view wx:ref class="title">this is view</view>
1480+
</template>
1481+
1482+
<script>
1483+
import { createComponent } from '@mpxjs/core'
1484+
1485+
createComponent({
1486+
ready() {
1487+
this.createSelectorQuery()
1488+
.select('.title')
1489+
.boundingClientRect(res => {
1490+
console.log('the rect res is:', res)
1491+
})
1492+
.exec()
1493+
}
1494+
})
1495+
</script>
1496+
```
14741497

14751498
### 样式规则
14761499
#### position

0 commit comments

Comments
 (0)