一、uniapp小程序点击某个事件,跳到指定位置
<view @click="but">按钮</view>
需求1:点击按钮跳到当前页面指定位置
but(){
uni.createSelectorQuery().select('.pinglun').boundingClientRect(data=>{
uni.createSelectorQuery().select(".pinglun_footer").boundingClientRect(res=>{
uni.pageScrollTo({
duration: 100,
scrollTop:data.top+300 - res.top,
})
}).exec()
}).exec();
}
需求2:点击按钮跳到当前页面最后的位置
but(){
uni.createSelectorQuery().select('.pinglun').boundingClientRect(data=>{
uni.createSelectorQuery().select(".pinglun_footer").boundingClientRect(res=>{
uni.pageScrollTo({
duration: 100,
scrollTop:100000000000
})
}).exec()
}).exec();
}