微信小程序实现锚点定位
·
回到页面最顶部
goTopOn: function (e) {
if (wx.pageScrollTo) {
wx.pageScrollTo({
scrollTop: 0
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,暂无法使用该功能,请升级后重试。'
})
}
},去到页面指定位置
jumpClick(){
let query = wx.createSelectorQuery();
let that = this;
query.select('#reservable').boundingClientRect(function (rect) {
that.setData({
height: rect.height
})
}).exec();
setTimeout(function(){
if (wx.pageScrollTo) {
let height = that.data.height
wx.pageScrollTo({
scrollTop: height
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,暂无法使用该功能,请升级后重试。'
})
}
},100)
},更多推荐
所有评论(0)