1、在scroll-view 标签上添加 @scrolltolower="onloadMore" 方法
<scroll-view class="scroll-view-box" scroll-y="true" @scrolltolower="onloadMore">
<view class="info">
<text class="info-text">内容展示在这里是上海市考核</text>
</view>
<uni-list>
<uni-list-item v-for="item in contentCate" :key="item" :title="item.name" ></uni-list-item>
</uni-list>
<uni-load-more :status="onload"></uni-load-more>
</scroll-view>
2、直接使用方法进行监听
onloadMore(){
console.log("到底了")
this.getList.push("你要添加的数据")
this.onload = "loading"
}
<uni-load-more :status="loading"></uni-load-more>
uni-load-more 插件可以进行加载动画,more ,loading,noMore 三种状态值。
3、父级标签如何监听滚动到底部,小程序生命周期带有的 onReachBottom 事件,他的作用就是监听页面滚动
onReachBottom() {
console.log("到底了");
}
还可以设置距离底部多少距离加载需要加载page.json中
"pages": [{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "app",
"onReachBottomDistance": 300 #距离底部300px 开始加载下面的数据
}
}],