监听页面滚动
页面,通过生命周期函数
onPageScroll(res) {
console.log("页面滚动了")
uni.$emit('onPageScroll', res.scrollTop)
}
组件,通过调用方法,监听页面滚动事件
mounted() {
var that = this
uni.$on('onPageScroll', function(data) {
console.log("页面滚动了")
console.log('data=',data)
//执行其他内容
})
},
上拉加载,组件触底分页加载
页面,通过生命周期函数
onReachBottom() {
uni.$emit('onReachBottom')
},
组件,通过调用方法
mounted() {
let that=this
uni.$once('onReachBottom',function(data){
console.log('触底了!')
that.getList()
})
}