uniapp实现不同的样式的分页器

前言

Uni-pagination是一个基于Vue.js的分页组件,提供了简单易用的分页功能。它可以自动计算并展示页码,根据设定的每页显示数量和总数据量,实现分页效果。Uni-pagination支持跳转到指定页码、上一页、下一页、首页和尾页等功能,并且可以自定义样式和回调函数。它可以应用于各种类型的数据列表,帮助用户轻松管理大量数据的分页展示。


提示:以下是本篇文章正文内容,下面案例可供参考

uni-notice-bar组件具有以下特点::

1、简洁易用:uni-pagination提供了简洁的API,使用起来非常方便。只需要传入总页数和当前页码,即可实现分页功能。
2、简洁易用:uni-pagination提供了简洁的API,使用起来非常方便。只需要传入总页数和当前页码,即可实现分页功能。
3、响应式设计:uni-pagination会根据视口大小自动调整显示的页码数量,以适应不同的设备和屏幕大小。
4、支持事件绑定:uni-pagination支持绑定多个事件,例如点击页码、上一页、下一页等,方便用户进行交互操作。
5、兼容性强:uni-pagination兼容大部分主流浏览器,并且支持移动端和PC端的使用。

如下图所示,本篇文章展示了非常多的用法和示例代码

在这里插入图片描述

<template>
	<view>
		<uni-card is-full :is-shadow="false">
			<text class="uni-h6">分页器组件,用于展示页码、请求数据等</text>
		</uni-card>
		<uni-section title="默认样式" type="line" padding>
			<uni-pagination :total="50" title="标题文字" />
		</uni-section>
		<uni-section title="修改按钮文字" subTitle="使用 prev-text / next-text 属性修改按钮文字" type="line" padding>
			<uni-pagination :total="50" title="标题文字" prev-text="前一页" next-text="后一页" />
		</uni-section>
		<uni-section title="图标样式" subTitle="使用 show-icon 属性显示图标按钮" type="line" padding>
			<uni-pagination :show-icon="true" :total="50" title="标题文字" />
		</uni-section>
		<uni-section title="修改数据长度" type="line" padding>
			<uni-pagination :current="current" :total="total" title="标题文字" :show-icon="true" @change="change" />
			<view class="btn-view">
				<view>
					<text class="example-info">当前页:{{ current }},数据总量:{{ total }}条,每页数据:{{ pageSize }}</text>
				</view>
				<view class="btn-flex">
					<button class="button word-btn" hover-class="word-btn--hover" :hover-start-time="20"
						:hover-stay-time="70" @click="add"><text class="word-btn-white">增加10条数据</text></button>
					<button class="button" type="default" @click="reset">重置数据</button>
				</view>
			</view>
		</uni-section>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				current: 3,
				total: 10,
				pageSize: 10
			}
		},
		mounted() {
			setTimeout(() => {
				this.current = 5
			}, 3000)
		},
		methods: {
			add() {
				this.total += 10
			},
			reset() {
				this.total = 0
				this.current = 1
			},
			change(e) {
				console.log(e)
				this.current = e.current
			}
		}
	}
</script>

<style lang="scss">
	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
	}

	.btn-view {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: column;
		/* #endif */
		padding: 15px;
		text-align: center;
		background-color: #fff;
		justify-content: center;
		align-items: center;
	}

	.btn-flex {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.button {
		margin: 20px;
		width: 150px;
		font-size: 14px;
		color: #333;
	}
</style>



API
在这里插入图片描述

总的来说,uni-pagination是一个简单易用且功能强大的分页组件,适用于各种类型的项目。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZL_567

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值