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);
		}
    });
},
相关推荐
喝拿铁写前端1 小时前
前端开发者使用 AI 的能力层级——从表面使用到工程化能力的真正分水岭
前端·人工智能·程序员
wuhen_n2 小时前
LeetCode -- 15. 三数之和(中等)
前端·javascript·算法·leetcode
七月shi人2 小时前
AI浪潮下,前端路在何方
前端·人工智能·ai编程
非凡ghost2 小时前
MusicPlayer2(本地音乐播放器)
前端·windows·学习·软件需求
脾气有点小暴2 小时前
scroll-view分页加载
前端·javascript·uni-app
beckyye3 小时前
ant design vue Table根据数据合并单元格
前端·antd
布列瑟农的星空3 小时前
还在手动翻译国际化词条?AST解析+AI翻译实现一键替换
前端·后端·ai编程
土豆12503 小时前
Rust 错误处理完全指南:从入门到精通
前端·rust·编程语言
QT 小鲜肉3 小时前
【Linux命令大全】001.文件管理之mmove命令(实操篇)
linux·服务器·前端·chrome·笔记