1.滚动事件
onPageScroll相当 JavaScript的scroll事件.
代码里面的e形参代表scrolltop(屏幕从上到下的滚动距离)
text
onPageScroll:function(e){ console.log(e); //{scrollTop:99} }
这种方法比onPageScroll处理动画和控制滚动位置控制更加灵活
https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
2.记录设备屏幕高度和宽
这个记录屏幕宽可以写轮播组件和动画组件
text
onLoad:function(){ wx.getSystemInfo({ success:function(res){ console.log(res); //屏幕宽度、高度 console.log(‘height=’+res.windowHeight); console.log(‘width=’+res.windowWidth); } }) }