本文共 780 字,大约阅读时间需要 2 分钟。
由于自定义底部tab栏在安卓机下拉时会跟随下滑,所以针对这种情况,就产生了一种解决方案,购物袋页面在安卓机下拉时不刷新,ios下拉时刷新。
思路:
1.不用小程序的下拉刷新~真正用的是onPageScroll,基于ios可以下滑时有一个滚动的效果但是安卓机没有这个特点实现的
代码:
1.json 禁止下拉属性
{ "usingComponents": { }, "navigationBarTitleText": "购物袋", "enablePullDownRefresh":false}
2.cart.js中添加滚动时刷新代码
onPageScroll: util.throttle(function (e) { //throttle是一个指定时间内多次调用但只触发一次的时间方法 if (e.scrollTop<=0){ this.getCartList(); //刷新时调用的方法 } },2000),
3.throttle方法(写在util.js中但是在cart.js中需要应用)
// 函数节流 防止用户多次点击触发function throttle(fn, gapTime) { if (gapTime == null || gapTime == undefined) { gapTime = 1500 } let _lastTime = null return function () { let _nowTime = + new Date() if (_nowTime - _lastTime > gapTime || !_lastTime) { fn.apply(this, arguments) _lastTime = _nowTime } }}
转载地址:http://qrpzb.baihongyu.com/