移动端表格分页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()
			},
		}
  }
相关推荐
jin1233224 小时前
基于React Native鸿蒙跨平台地址管理是许多电商、外卖、物流等应用的重要功能模块,实现了地址的添加、编辑、删除和设置默认等功能
javascript·react native·react.js·ecmascript·harmonyos
2501_920931705 小时前
React Native鸿蒙跨平台医疗健康类的血压记录,包括收缩压、舒张压、心率、日期、时间、备注和状态
javascript·react native·react.js·ecmascript·harmonyos
落霞的思绪5 小时前
配置React和React-dom为CDN引入
前端·react.js·前端框架
Hacker_Z&Q5 小时前
CSS 笔记2 (属性)
前端·css·笔记
Anastasiozzzz5 小时前
LeetCode Hot100 295. 数据流的中位数 MedianFinder
java·服务器·前端
橙露6 小时前
React Hooks 深度解析:从基础使用到自定义 Hooks 的封装技巧
javascript·react.js·ecmascript
Exquisite.6 小时前
Nginx
服务器·前端·nginx
2501_920931706 小时前
React Native鸿蒙跨平台使用useState管理健康记录和过滤状态,支持多种健康数据类型(血压、体重等)并实现按类型过滤功能
javascript·react native·react.js·ecmascript·harmonyos
打小就很皮...6 小时前
dnd-kit 实现表格拖拽排序
前端·react.js·表格拖拽·dnd-kit
Ulyanov6 小时前
从静态到沉浸:打造惊艳的Web技术发展历程3D时间轴
前端·javascript·html5·gui开发