文件路径:
/pages/index/index.vue
onShow里面加入下面红框里面的代码
代码:
that.$nextTick(function() {
const query = uni.createSelectorQuery();
query.select('#home').boundingClientRect(); //获取当前元素距离顶部的距离
query.exec(res =>{
if(res[0].top <= -60)that.isScrolled = true
})
})