Mini Program to Implement Paging Effect

Mini Program to Implement Paging Effect

This article example shares the specific code for the mini program to achieve paging effect display for your reference. The specific content is as follows

<view class="pages_box">
  <view bindtap="pagesFn" class="{{pagesNum==0?'active':''}}" data-type="0">Previous page</view>
  <block wx:for="shujuDataArr11111" wx:key="index" wx:if="{{index+1<4}}">
    <view wx:if="{{tyindex+index <=maxPages}}" bindtap="pagesFn" class="{{pagesNum==tyindex+index?'active':''}}" data-type="{{tyindex+index}}">{{tyindex+index}}</view>
  </block>
  <view bindtap="pagesFn" class="{{pagesNum==-1?'active':''}}" data-type="-1">Next page</view>
</view>

js:

// pages/ceshiPages/index.js
Page({
 
  /**
   * Initial data of the page */
  data: {
    pagesNum:1,
    maxPages:15, //Total number of pages tyindex:1
  },
 
  /**
   * Life cycle function--listen for page loading*/
  onLoad: function (options) {
 
  },
    pagesFn:function(e){
    let type = e.currentTarget.dataset.type;
    let _that = this;
    if(typeof type == "string"){//Next pageif(type == "previous_page"){//Previous pageif(_that.data.pagesNum-1 >0){
          _that.setData({
            pagesNum:_that.data.pagesNum-1,
            tyindex:_that.data.pagesNum-1,
          })
        }
        console.log(_that.data.pagesNum)
      }else{//Next pageif(_that.data.pagesNum+1 <= _that.data.maxPages){
          if((_that.data.pagesNum+1)%3 == 0){
            _that.setData({
              tyindex:_that.data.pagesNum+1,
            })
          }
          _that.setData({
            pagesNum:_that.data.pagesNum+1,
          })
          console.log(_that.data.pagesNum)
        }
      }
    }else{
      console.log(_that.data.pagesNum)
      if(type>_that.data.pagesNum){
        if(type <= _that.data.maxPages){
          _that.setData({
            tyindex:type,
            pagesNum:type,
          })
        }
      }
      if(type<_that.data.pagesNum){
        if(type >=1){
          _that.setData({
            tyindex:type,
            pagesNum:type,
          })
        }
      }
      console.log(_that.data.pagesNum)
    }
  },
  /**
   * Life cycle function - listen for the completion of the initial rendering of the page*/
  onReady: function () {
 
  },
 
  /**
   * Life cycle function--monitor page display*/
  onShow: function () {
 
  },
 
  /**
   * Life cycle function--listen for page hiding*/
  onHide: function () {
 
  },
 
  /**
   * Life cycle function--monitor page uninstallation*/
  onUnload: function () {
 
  },
 
  /**
   * Page related event processing function - listen to user pull-down action */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * The function that handles the bottoming event on the page*/
  onReachBottom: function () {
 
  },
 
  /**
   * User clicks on the upper right corner to share*/
  onShareAppMessage: function () {
 
  }
})

CSS:

/* pages/ceshiPages/index.wxss */
.pages_box{
  margin-top: 20rpx;
  display: flex;
  display: -webkit-flex;
  flex-direction: row;
  justify-content: space-around;
  align-content: flex-start;
  flex-wrap: nowrap;
}
.pages_box>view{
  line-height: 60rpx;
  font-size: 30rpx;
  border: 1px solid #A0A0A0;
  background-color: #F7F7F7;
  display: inline-block;
  padding: 0 25rpx;
  margin-left: 12rpx;
  color: #64646C;
  border-radius: 10rpx;
}
.pages_box>view.active{
  background-color: #FCD821;
  border-color: #F39800;
}
.pages_box>view:last-child,.pages_box>view:first-child{
  border-radius: 60rpx;
  padding: 0 30rpx;
}

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • WeChat applet realizes paging loading effect
  • Implementation code of search paging function of WeChat applet
  • Mini Program Paging Practice: Writing Reusable Paging Components
  • WeChat applet cloud development realizes data addition, query and paging
  • Example code for paging loading of WeChat applet
  • WeChat applet realizes mobile sliding paging effect (ajax)
  • Pull-up (page loading) effect in actual WeChat mini program (2)
  • WeChat applet template paging sliding bar

<<:  Deleting the database and running away? How to use xtraback to back up the MySQL database

>>:  Tutorial on binary compilation and installation of MySql centos7 under Linux

Recommend

CSS3 border effects

What is CSS# CSS (abbreviation of Cascading Style...

Implementation process of row_number in MySQL

1. Background Generally, in a data warehouse envi...

Analysis of MySQL joint index function and usage examples

This article uses examples to illustrate the func...

Detailed tutorial on building an ETCD cluster for Docker microservices

Table of contents Features of etcd There are thre...

CSS3 uses the transition property to achieve transition effects

Detailed description of properties The purpose of...

jQuery plugin to achieve image comparison

This article example shares the specific code of ...

MySQL sorting using index scan

Table of contents Install sakila Index Scan Sort ...

Solution for installing opencv 3.2.0 in Ubuntu 18.04

Download opencv.zip Install the dependencies ahea...

Vue component communication method case summary

Table of contents 1. Parent component passes valu...

Example code of layim integrating right-click menu in JavaScript

Table of contents 1. Effect Demonstration 2. Impl...

Solution to Ubuntu cannot connect to the network

Effective solution for Ubuntu in virtual machine ...

Analysis of the Poor Performance Caused by Large Offset of LIMIT in MySQL Query

Preface We all know that MySQL query uses the sel...

CSS position fixed left and right double positioning implementation code

CSS Position The position attribute specifies the...

Diagram of the process of implementing direction proxy through nginx

This article mainly introduces the process of imp...

Detailed explanation of Linux commands sort, uniq, tr tools

Sort Tool The Linux sort command is used to sort ...