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();
