<scroll-view scroll-y class="left_menu" style="height: 300rpx;">
<view class="menu_item" bindtap="handleItemTab" >{{item}}</view>
</scroll-view>
更多属性请查看: (https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html)
wx.pageScrollTo({
scrollTop: 0,
duration: 300 //滚动到顶部所需要的事件
})
上拉加载更多有两种实现方式
1.监听scroll-view上的bindscrolltoupper
事件
<scroll-view scroll-y="true" style="height: 300rpx;" bindscrolltoupper="upper"></scroll-view>
upper(e) {
console.log(‘请求更多数据‘)
},
2.使用小程序的声明周期函数onReachBottom()
onReachBottom(){
console.log(‘请求更多数据‘)
}
onPullDownRefresh()
方法可刷新页面,默认刷新时间为2s,因此当成功请求到数据时,我们通过手动的调用wx.stopPullDownRefresh()
关闭刷新可以带来更佳的用户体验onPullDownRefresh() {
// 重置商品数组
this.setData({
goodsList: [],
})
// 重置页码
this.QueryParams.pagenum = 1
// 重新请求商品
this.getGoodsList()
}
getGoodsList() {
...
console.log(‘成功请求到数据‘)
// 手动关闭刷新过程
wx.stopPullDownRefresh()
}
"enablePullDownRefresh": true
,用于开启页面下拉加载效果 "window": {
"enablePullDownRefresh": true //全局
"backgroundTextStyle": "dark" //顶部显示颜色为白色的三个点
}
原文:https://www.cnblogs.com/jincanyu/p/14349244.html