Get slip distance
Wechat applet has a function called onPageScroll that can get the distance of the current sliding screen.
onPageScroll: function(res) {
console.log(res);
},
Copy the code
The sliding distance is printed as follows:
Return to the top
1. Set scrollTop:0 in data
2, click click to return to the top of the method, as follows:
GoScrolltop :function(e){if (wx.pagesCrollto){wx.pagescrollto ({scrollTop: 0})} else {wx.showmodal ({title: 'Warning ', content:' The current wechat version is too early to use this function, please upgrade to the latest wechat version and try again. '})}},Copy the code