<template>
<scroll-view id="scrollview" scroll-y="true" :style="{height:scrollHeight+'px'}" :scroll-top="scrollTop"
</scroll-view>
</template>
如果scroll-view外层没有view或者其他元素包住的话,query查询的话会是null
let query = uni.createSelectorQuery().in(this)
query.select('#scrollview').boundingClientRect()
query.exec((res) => {
//res会是null
});
<template>
<view>
<scroll-view id="scrollview" scroll-y="true" :style="{height:scrollHeight+'px'}" :scroll-top="scrollTop"
</scroll-view>
</view>
</template>
如果scroll-view外层有内容包住之后,query才能查询出来信息
let query = uni.createSelectorQuery().in(this)
query.select('#scrollview').boundingClientRect()
query.exec((res) => {
//res会是null
});
网友评论