diff --git a/docs/api/ui/nodes-info.md b/docs/api/ui/nodes-info.md index 5b00948b905d6df4df09fd24a4af38ae5f75faca..81c5f3832093fa2b69d8349c98f4994cc45f6f28 100644 --- a/docs/api/ui/nodes-info.md +++ b/docs/api/ui/nodes-info.md @@ -19,6 +19,10 @@ **代码示例** +::: preview + +> 选项式 API + ```javascript const query = uni.createSelectorQuery().in(this); query @@ -30,6 +34,22 @@ query .exec(); ``` +> 组合式 API + +```javascript +import { getCurrentInstance } from 'vue'; +const instance = getCurrentInstance(); + +const query = uni.createSelectorQuery().in(instance.proxy); +query + .select("#id") + .boundingClientRect((data) => { + console.log("得到布局位置信息" + JSON.stringify(data)); + console.log("节点离页面顶部的距离为" + data.top); + }) + .exec(); +``` + **注意** - 支付宝小程序不支持 in(component),使用无效果