移动端表格分页uni-app

使用uni-app提供的uni-table表格

网址:https://uniapp.dcloud.net.cn/component/uniui/uni-table.html#介绍

xml 复制代码
<uni-table ref="table" :loading="loading" border stripe type="selection" emptyText="暂无更多数据"
	@selection-change="selectionChange">
		<uni-tr>
			<uni-th width="100" align="center">资产名称</uni-th>
			<uni-th width="90" align="center">资产类别</uni-th>
			<uni-th width="80" align="center">原使用部门</uni-th>
			<uni-th width="50" align="center">操作</uni-th>
		</uni-tr>
		<uni-tr v-for="(item, index) in shenpilist" :key="index" :label="item.name" :name="item.name">
			<uni-td align="center">{{ item.assetName }}</uni-td>
			<uni-td align="center">{{ item.categoryName }}</uni-td>
			<uni-td align="center">{{ item.deptName }}</uni-td>
			<uni-td align="center">
				<button class="uni-button" size="mini" type="primary" @click="onModalState(item)">详情</button>
			</uni-td>
		</uni-tr>
	</uni-table>
<view class="uni-pagination-box"><uni-pagination show-icon  :current="queryParams.pageNum"
 :total="total" @change="change" /></view>
javascript 复制代码
import {getAssets} from '@/api/subpkg/index.js'
export default {
		data() {
			return {
			// 列表数据
			shenpilist: [],
			// 参数列表
			queryParams: {
				pageNum: 1,
				pageSize: 10,
				category: undefined,
				assetCode: '',
				assetName: '',
			},
			total: null,//总数据
			}
		},
		methods:{
			async getAssets() {
				const data = {
					isForceAllocate: this.value.indexOf('是否强制调拨') !== -1 ? 1 : 0,
					query: this.queryParams
				}
				const res = await getAssets(data)
				uni.hideLoading()
				this.shenpilist = res.rows
				this.total = res.total; 
				console.log(this.total);
			},
			// 分页触发
			change(e) {
			console.log(e.current);
				this.queryParams.pageNum = e.current;
				uni.showLoading({
					title: '数据加载中',
					mask: true,
				});
				//分页切换之后,在发一次请求,使数据更新
				this.getAssets()
			},
		}
  }
相关推荐
im_AMBER22 分钟前
React 17
前端·javascript·笔记·学习·react.js·前端框架
一雨方知深秋29 分钟前
2.fs模块对计算机硬盘进行读写操作(Promise进行封装)
javascript·node.js·promise·v8·cpython
谷歌开发者1 小时前
Web 开发指向标 | Chrome 开发者工具学习资源 (六)
前端·chrome·学习
一晌小贪欢1 小时前
【Html模板】电商运营可视化大屏模板 Excel存储 + 一键导出(已上线-可预览)
前端·数据分析·html·excel·数据看板·电商大屏·大屏看板
发现你走远了1 小时前
连接模拟器网页进行h5的调试(使用Chrome远程调试(推荐)) 保姆级图文
前端·chrome
街尾杂货店&3 小时前
css - 实现三角形 div 容器,用css画一个三角形(提供示例源码)简单粗暴几行代码搞定!
前端·css
顺凡3 小时前
删一个却少俩:Antd Tag 多节点同时消失的原因
前端·javascript·面试
小白路过3 小时前
CSS transform矩阵变换全面解析
前端·css·矩阵
爬山算法3 小时前
Redis(110)Redis的发布订阅机制如何使用?
前端·redis·bootstrap
REDcker3 小时前
前端打包工具 - Rollup 打包工具笔记
前端·笔记