<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 //滾動(dòng)到頂部所需要的事件
})
上拉加載更多有兩種實(shí)現(xiàn)方式
1.監(jiān)聽scroll-view上的bindscrolltoupper事件
<scroll-view scroll-y="true" style="height: 300rpx;" bindscrolltoupper="upper"></scroll-view>
upper(e) {
console.log('請求更多數(shù)據(jù)')
},
2.使用小程序的聲明周期函數(shù)onReachBottom()
onReachBottom(){
console.log('請求更多數(shù)據(jù)')
}
復(fù)制onPullDownRefresh() {
// 重置商品數(shù)組
this.setData({
goodsList: [],
})
// 重置頁碼
this.QueryParams.pagenum = 1
// 重新請求商品
this.getGoodsList()
}
getGoodsList() {
...
console.log('成功請求到數(shù)據(jù)')
// 手動(dòng)關(guān)閉刷新過程
wx.stopPullDownRefresh()
}
"window": {
"enablePullDownRefresh": true //全局
"backgroundTextStyle": "dark" //頂部顯示顏色為白色的三個(gè)點(diǎn)
}