Skip to content

Commit

Permalink
docs: update nvue uni.createSelectorQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
dcloudhdx committed Sep 21, 2019
1 parent f50f01b commit 8a6b0cc
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion docs/api/ui/nodes-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,52 @@ view.boundingClientRect(data => {
console.log("得到布局位置信息" + JSON.stringify(data));
console.log("节点离页面顶部的距离为" + data.top);
}).exec();
```
```

**注意**
- nvue 暂不支持 uni.createSelectorQuery,暂时使用下面的方案

```
<template>
<view class="wrapper">
<view ref="box" class="box">
<text class="info">Width: {{size.width}}</text>
<text class="info">Height: {{size.height}}</text>
<text class="info">Top: {{size.top}}</text>
<text class="info">Bottom: {{size.bottom}}</text>
<text class="info">Left: {{size.left}}</text>
<text class="info">Right: {{size.right}}</text>
</view>
</view>
</template>
<script>
// 注意平台差异
// #ifdef APP-NVUE
const dom = weex.requireModule('dom')
// #endif
export default {
data () {
return {
size: {
width: 0,
height: 0,
top: 0,
bottom: 0,
left: 0,
right: 0
}
}
},
onReady () {
const result = dom.getComponentRect(this.$refs.box, option => {
console.log('getComponentRect:', option)
this.size = option.size
})
console.log('return value:', result)
console.log('viewport:', dom.getComponentRect('viewport'))
}
}
</script>
```

0 comments on commit 8a6b0cc

Please sign in to comment.