移动端表格分页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()
			},
		}
  }
相关推荐
锋行天下8 分钟前
LangGraph 对接 MCP 实战指南:从本地开发到线上部署与模型防坑
前端·人工智能·后端
Highcharts.js35 分钟前
Highcharts与TypeScript集成指南
前端·javascript·typescript·前端框架·数据可视化·highcharts
跳跳的小古风1 小时前
前端转全栈:一条接口从前端请求到 SQL 完整流程
java·前端
亿元程序员1 小时前
微信小游戏备案很久?这样操作可以直接发布!
前端
福狼2 小时前
The Expanse:让风沙成为世界的一部分
前端·three.js
桃李无言下自成蹊2 小时前
为什么越清晰的二维码越扫不出来:jsQR 四轮解码与 8 个真实坑
javascript
程序员鱼皮2 小时前
这 3 年 AI Agent 到底进化了啥?万字大白话,一次讲透!
前端·后端·aigc
用户900305093622 小时前
Claude Code平替评测:换掉之前先理清楚这些选型条件
前端
bai2732 小时前
同一个 JSON,Node 读出了三种坏法:Windows 上四种写法的编码实测
前端
ZANE2 小时前
纯前端实现的 .gitignore 生成器技术实现
前端