uni-app 页面滚动到指定位置

uni.createSelectorQuery().select(".app").boundingClientRect(data=>{//目标节点
  uni.createSelectorQuery().select(".al").boundingClientRect((res)=>{//最外层盒子节点
    uni.pageScrollTo({
      duration:0,//过渡时间必须为0,uniapp bug,否则运行到手机会报错
      scrollTop:res.top - data.top,//滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离
    })
  }).exec()
}).exec();
原文地址:https://www.cnblogs.com/fanqiuzhuji/p/12394823.html