uniapp-数据列表下拉刷新上拉加载

pages.json

{
    "path" : "pages/test/test",
    "style" :                                                                                    
    {
        "navigationBarTitleText": "测试页面",
        "enablePullDownRefresh": true, //下拉刷新
		"onReachBottomDistance": 160 // 上拉触底的单位,单位为px
    }
    
}

界面

<template>
		    <view>
		        <view v-for="(item,index) of newList" :key="index" class="newList">
		            {
  {item.LINE_NAME}}
		        </view>
		        <view class="loading">{
  {loadingTxt}}</view>
		    </view>
</template>

js

<script>
	let page=1,timer=null
	export default {
			data() {
			            return {
			                newList:[],
			                
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
uniapp中,可以使用 `uni-app` 组件库提供的 `uni-scroll-view` 组件来实现上拉加载下拉刷新功能。 下拉刷新: 1. 在 `template` 中添加 `uni-scroll-view` 组件,并设置 `refresher-enabled` 属性为 `true`,表示开启下拉刷新功能。 ```html <template> <uni-scroll-view refresher-enabled @scrolltolower="loadMore"> <!-- 列表数据 --> </uni-scroll-view> </template> ``` 2. 在 `methods` 中实现下拉刷新触发的函数。 ```js methods: { onRefresh() { // 执行下拉刷新操作 // 更新列表数据 // 停止下拉刷新 uni.stopPullDownRefresh(); } } ``` 3. 通过 `onPullDownRefresh` 生命周期钩子,在下拉刷新的时候触发 `onRefresh` 函数。 ```js methods: { onRefresh() { // 执行下拉刷新操作 // 更新列表数据 // 停止下拉刷新 uni.stopPullDownRefresh(); } }, onPullDownRefresh() { this.onRefresh(); } ``` 上拉加载: 1. 在 `template` 中添加 `uni-scroll-view` 组件,并设置 `scroll-into-view` 属性为 `scroll-view-anchor`,表示在滚动到指定锚点时触发上拉加载。 ```html <template> <uni-scroll-view scroll-into-view="scroll-view-anchor" @scrolltolower="loadMore"> <!-- 列表数据 --> <view id="scroll-view-anchor"></view> </uni-scroll-view> </template> ``` 2. 在 `methods` 中实现上拉加载触发的函数。 ```js methods: { loadMore() { // 执行上拉加载操作 // 更新列表数据 } } ``` 3. 在 `template` 中添加一个锚点元素,用来触发上拉加载。 ```html <template> <uni-scroll-view scroll-into-view="scroll-view-anchor" @scrolltolower="loadMore"> <!-- 列表数据 --> <view id="scroll-view-anchor"></view> </uni-scroll-view> </template> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xcLeigh

万水千山总是情,打赏两块行不行

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值