小程序实现点击分页
<view class="pBox" wx:if="{{nowPage > 0 && total > 0}}">
<!-- 左箭头 -->
<view class="item {{nowPage > 1 ? '' : 'opt'}}" bindtap="arrowleft" data-index="{{nowPage}}"
wx:if="{{showArrowLeft || alwaysShowArrow}}">
<image class="left" src="/pageleft.png"></image>
</view>
<view class="item {{nowPage - 1 == nowPage ? 'itemActive' : ''}}" wx:if="{{nowPage - 1 > 1}}" bindtap="click"
data-index="1">
<view class="">1</view>
</view>
<!-- 左侧省略号 -->
<view class="item {{nowPage - 1 == nowPage ? 'itemActive' : ''}}" wx:if="{{nowPage - 1 > 2}}">
...
</view>
<!-- 激活页的前一页 -->
<view class="item {{nowPage - 1 == nowPage ? 'itemActive' : ''}}" wx:if="{{nowPage - 1 > 0}}" bindtap="click"
data-index="{{nowPage - 1}}">
<view class="">{{ nowPage - 1 }}</view>
</view>
<!-- 激活页 -->
<view class="item {{nowPage == nowPage ? 'itemActive' : ''}}" wx:if="{{nowPage <= num}}" bindtap="click"
data-index="{{nowPage}}">
<view class="">{{ nowPage }}</view>
</view>
<!-- 激活页的后一页 -->
<view class="item {{nowPage + 1 == nowPage ? 'itemActive' : ''}}" wx:if="{{nowPage + 1 <= num}}" bindtap="click"
data-index="{{nowPage + 1}}">
<view class="">{{ nowPage + 1 }}</view>
</view>
<!-- 右侧省略号 -->
<view class="item" wx:if="{{num - nowPage - 2 >= 1}}">
...
</view>
<!-- 最后一页 -->
<view class="item" wx:if="{{num - nowPage - 2 >= 0}}" bindtap="click" data-index="{{num}}">
<view class="">{{ num }}</view>
</view>
<!-- 右箭头 -->
<view class="item {{nowPage < num ? '' : 'opt'}}" bindtap="arrowright" data-index="{{nowPage}}"
wx:if="{{showArrowRight || alwaysShowArrow}}">
<image class="left" src="/pageright.png"></image>
</view>
</view>
Component({
/**
* 组件的属性列表
*/
properties: {
type: {
type: String
},
// 每页显示条目个数
pageSize: {
type: Number,
default: 10
},
// 总数目
total: {
type: Number,
...
