<view id="container">
<view id="target"> </view>
</view>
uni.createSelectorQuery()
.select(".container")//对应外层节点
.boundingClientRect((container) => {
uni.createSelectorQuery()
.select("#target")//目标节点
.boundingClientRect((target) => {
uni.pageScrollTo({
scrollTop: target.top - container.top,//滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离
});
})
.exec();
})
.exec();