uniapp锚点定位功能的问题:

当我点击导航栏任意一个位置,即就会跳转相对应的位置,当我滚动页面上的内容,导航栏也会跟着选择相对应内容的位置
uniapp锚点定位功能的问题:

//点击事件的
uni.pageScrollTo({
scrollTop: document.querySelector("#scroll").offsetTop,
duration: 300
});
//滚动的
onPageScroll(e) {
const query = uni.createSelectorQuery().in(this);
query.select('#scroll').boundingClientRect(data => {
if (data.top<=45) {
this.tabindex = 0; //添加class改样式的
}
}).exec();
}