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);
		}
    });
},
相关推荐
万少4 小时前
HarmonyOS 开发必会 5 种 Builder 详解
前端·harmonyos
橙序员小站7 小时前
Agent Skill 是什么?一文讲透 Agent Skill 的设计与实现
前端·后端
炫饭第一名9 小时前
速通Canvas指北🦮——基础入门篇
前端·javascript·程序员
王晓枫9 小时前
flutter接入三方库运行报错:Error running pod install
前端·flutter
符方昊9 小时前
React 19 对比 React 16 新特性解析
前端·react.js
ssshooter10 小时前
又被 Safari 差异坑了:textContent 拿到的值居然没换行?
前端
曲折10 小时前
Cesium-气象要素PNG色斑图叠加
前端·cesium
Forever7_10 小时前
Electron 淘汰!新的桌面端框架 更强大、更轻量化
前端·vue.js
Angelial10 小时前
Vue3 嵌套路由 KeepAlive:动态缓存与反向配置方案
前端·vue.js
jiayu10 小时前
Angular学习笔记24:Angular 响应式表单 FormArray 与 FormGroup 相互嵌套
前端