uni-app中表格分页

样式:

代码实现:

template

复制代码
<uni-table ref="table" border stripe emptyText="暂无更多数据">
	<uni-tr>
		<uni-th width="150" align="center">库位名称</uni-th>
		<uni-th width="150" align="center">库位编码</uni-th>
	</uni-tr>
	<uni-tr v-for="(item, index) in list" :key="index" @row-click="handleRowClick(item, $event)">
		<uni-td align="center">{{ item.locationName }}</uni-td>
        <uni-td align="center">{{ item.locationCode }}</uni-td>
	</uni-tr>
</uni-table>
	<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize"
:current="pageCurrent" :total="total" @change="change" /></view>

script

复制代码
data() {
			return {
				list: [],
				selectedIndexs: [],
                pageCurrent: 1,       // 当前页码(从1开始)
                pageSize: 10,         // 每页条数
                total: 0,             // 总条数(用于分页控件)
				loading: false,
			}
		},
// 分页触发
			change(e) {
				// this.$refs.table.clearSelection()
				// this.selectedIndexs.length = 0
				this.handleLocationCode(e.current)
			},
	
			handleLocationCode(pageIndex) {
				let data = {
					UserName: this.userInfo.UserName,
					Type: "1",
					PageIndex: pageIndex ? pageIndex : 1,
					PageSize: 10,
					MenuCode: 'UnitLoadInTask'
				};
				console.log('获取起点', data)
				GetPlainLocations(data)
					.then(res => {
						console.log('获取起点提交成功', res.data)
						
				this.list = res.data.data
			console.log(this.list)
      // ✅ 从任意一条记录中取总条数(因为每条都有 TotalNum)
     // 如果 data 为空,则 total = 0
	this.total = res.data.data.length > 0 ? res.data.data[0].TotalNum : 0;
	// 同步当前页码
	this.pageCurrent = pageIndex;
	
					})
					.catch(err => {
						console.error('请求失败:', err);
						this.list = [];
						this.total = 0;
					});

			},
相关推荐
码兄科技1 天前
24小时自助健身房系统软件开发实战指南:功能设计与部署方案
java·spring boot·uni-app
2501_916007471 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
2501_916008891 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
2501_916008891 天前
怎么用 Godot 导出 iOS 应用并上架 App Store?签名字段该填什么?
android·ios·小程序·https·uni-app·iphone·webview
郑州光合科技余经理2 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
白远山2 天前
城市电竞陪玩调度系统实战:从派单算法到多端协同的架构拆解
java·架构·uni-app·需求分析
白远山3 天前
上海24小时自助健身房系统软件开发实战指南
java·架构·uni-app·需求分析
白远山4 天前
上海24小时自助健身房系统软件开发实战指南:从需求到部署
java·架构·uni-app·需求分析
海鸥两三4 天前
小程序文档预览 · 进阶面试题
小程序·uni-app·uniapp
海鸥两三4 天前
微信小程序 PDF 预览实践(uni.downloadFile → uni.openDocument)
小程序·uni-app