小程序实现点击分页

发布于 3 年前作者 tanchao2988 次浏览最后编辑 3 年前来自 share

<view class="pBoxwx:if="{{nowPage > 0 && total > 0}}">

    <!-- 左箭头 -->

    <view class="item {{nowPage > 1 ? '' : 'opt'}}" bindtap="arrowleftdata-index="{{nowPage}}"

        wx:if="{{showArrowLeft || alwaysShowArrow}}">

        <image class="leftsrc="/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="itemwx:if="{{num - nowPage - 2 >= 1}}">

        ...

    </view>


    <!-- 最后一页 -->

    <view class="itemwx:if="{{num - nowPage - 2 >= 0}}" bindtap="clickdata-index="{{num}}">

        <view class="">{{ num }}</view>

    </view>


    <!-- 右箭头 -->

    

    <view class="item {{nowPage < num ? '' : 'opt'}}" bindtap="arrowrightdata-index="{{nowPage}}"

        wx:if="{{showArrowRight || alwaysShowArrow}}">

        <image class="leftsrc="/pageright.png"></image>

    </view>

</view>




Component({

    /**

     * 组件的属性列表

     */

    properties: {

        type: {

            type: String

        },

        // 每页显示条目个数

        pageSize: {

            type: Number,

            default: 10

        },

        // 总数目

        total: {

            type: Number,

...

0 回复
暂无回复