3 Star 6 Fork 4

Gitee 极速下载 / Pagination

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/liverwang/Pagination
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Pagination

基于 jQuery 的简单 JavaScript 分页组件

使用方法

  1. 引用jQuery
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
  1. 引用Pagination
  <script src="./pagination/pagination.js"></script>
  1. 页面指定分页组件容器:可以使用classid,实现多个分页
  <div class="row ">
    <div class="page-container"></div>
  </div>
  1. 实例化分页组件
const pageSize = 10 // 默认页码大小
const dataCount = 95 // 测试数据数量
const pager = new Pagination('.page-container', {
  pageSize: pageSize,
  autoLoad: true,
  unit: '',
  toPage: function(index, _pageSize) {
    // 设置记录总数,用于生成分页HTML内容
    if (index === 0 || _pageSize) this.updateCount(dataCount, _pageSize)

    // 根据页码以及分页大小生成html内容
    let pageListHtml = ''
    for (var i = 0; i < (_pageSize || pageSize); i++) {
      pageListHtml += `
          <div class="col-md-3">
            <div class="card">
              <div class="card-body">
                <h5 class="card-title">Card - ${index *
                  (_pageSize || pageSize) +
                  i +
                  1}</h5>
                <p class="card-text">card-text,card-text,card-text,card-text</p>
              </div>
            </div>
          </div>
        `
    }
    $('.page-list').html(pageListHtml)
  }
})
  1. 查看效果:JavaScript分页组件

兼容性

chrome firefox safari edge ie9以上

MIT License Copyright (c) 2018 liverwang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Pagination 是一个基于 jQuery 实现的一个简单的 JavaScript 分页组件,主要实现以下功能: 1. 方便在 JavaScript 中对后端分页数据进行展示 展开 收起
JavaScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/mirrors/Pagination.git
git@gitee.com:mirrors/Pagination.git
mirrors
Pagination
Pagination
master

搜索帮助