Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report]通过refs获取的 组件实例top怎么获取 #1613

Closed
keke599 opened this issue Sep 10, 2024 · 1 comment
Closed

[Bug report]通过refs获取的 组件实例top怎么获取 #1613

keke599 opened this issue Sep 10, 2024 · 1 comment

Comments

@keke599
Copy link

keke599 commented Sep 10, 2024

类似小程序中的
const query = wx.createSelectorQuery()
query.select('#the-id').boundingClientRect(function(res){
res.top // #the-id 节点的上边界坐标(相对于显示区域)
})
query.selectViewport().scrollOffset(function(res){
res.scrollTop // 显示区域的竖直滚动位置
})
query.exec()

@kimi233
Copy link
Collaborator

kimi233 commented Sep 12, 2024

直接通过 ref 对象调用 boundingClientRect 方法即可,例如

<view wx:ref="box"></view>

this.$refs.box.boundingClientRect(function(res){
  // ...
}).exec()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants