uni-app scroll-view特定情况下运用

javascript 复制代码
//下拉刷新,需要自己在page.json文件中配置开启页面下拉刷新 "enablePullDownRefresh": true
onPullDownRefresh:function() {
    setTimeout(()=>{
		this.param.page = 1;
		this.totalPage = 0;
		this.list=[];
		this.getlist();
        uni.stopPullDownRefresh();
    }, 1000);
},
javascript 复制代码
//上拉加载,需要自己在page.json文件中配置"onReachBottomDistance"
onReachBottom:function(){
	if(this.param.page>= this.totalPage){
		this.status = 'noMore';
		return false;
	}else{
		this.status = 'loading';
	}
	this.param.page += 1;
	this.getlist();
},

如果page中css样式设置了height:100%后, 页面的上拉 下拉就不生效了,有时又需要设置高度100% 来构建页面样式,这种情况下就得运用 scroll-view 来分页数据了

javascript 复制代码
<scroll-view ref="add" :scroll-y="true" style="flex: 1;overflow-y: auto;" class="order-list" @scrolltolower="scrollView">
scrollView() {
	// 数据加载到与总数量一样
	if (this.list.length == this.total) {
		uni.showToast({
			title: '翻到底了!',
			icon: "none"
		});
		return false
	}
	uni.showLoading({
		mask: true,
		title: "加载中"
	})
	setTimeout(() => {
		uni.hideLoading()
		this.param.page++;
		this.getlist();
	}, 500)
},
javascript 复制代码
getlist:function(){
	this.isLoading = true;
	this.majax({url:this.$local + 'pos/book/restock/page', params:this.param,method:'POST'}).then(res => {
		this.isLoading = false;
		if(res.code === 0){
			let mlist = res.data.records.map(item => {
				item.flag = false
				item.sl = item.ygbsl
				return {...item}
			});
			this.total = res.data.total
			this.totalPage = res.data.pages;
		  for (let i = 0; i < mlist.length; i++) {
			this.list.push(mlist[i])
		  }
		}else{
		  this.goout(res);
		}
    });
},
相关推荐
摘星编程5 小时前
React Native for OpenHarmony 实战:Picker 选择器组件详解
javascript·react native·react.js
摘星编程5 小时前
React Native for OpenHarmony 实战:VirtualizedList 虚拟化列表
javascript·react native·react.js
谢尔登6 小时前
Vue3 响应式系统——computed 和 watch
前端·架构
愚公移码6 小时前
蓝凌EKP产品:主文档权限机制浅析
java·前端·数据库·蓝凌
摘星编程6 小时前
React Native for OpenHarmony 实战:RefreshControl 下拉刷新组件
javascript·react native·react.js
欣然~7 小时前
法律案例 PDF 批量转 TXT 工具代码
linux·前端·python
一个小废渣7 小时前
Flutter Web端网络请求跨域错误解决方法
前端·flutter
2501_915909068 小时前
原生与 H5 共存情况下的测试思路,混合开发 App 的实际测试场景
android·ios·小程序·https·uni-app·iphone·webview
鸣弦artha8 小时前
Flutter框架跨平台鸿蒙开发——Extension扩展方法
android·javascript·flutter
符文师8 小时前
css3 新特性
前端·css3