2、实现过程在前端通过ajax请求数据后,可以通过bootstrap实现分页。由于bootstrap只提供分页的按钮的样式。数据分页我们需要实现页码跳转,上一页下一页,数据过多显示省略号,点击省略号能快速切换到其他页的数据。
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>分页title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
head>
<body>
<nav aria-label="Page navigation" style="margin-top: 50px;">
<input type="text" name="pagenumber" value="1" hidden />
<ul class="pagination">ul>
nav>
body>
<script src="https://cdn.staticfile.org/jquery/1.10.0/jquery.min.js" type="text/javascript" charset="utf-8">script>
<script type="text/javascript">
$(document).ready(function () {
let total = 200; // 数据总条数
let PageIndex = 1;// 当前页
let PageSize = 10; //一页显示10条
let pageHtml = $('.pagination'); // 分页栏
let totalPage = Math.ceil(total / PageSize); // 获取到总页数
function setPages() {
let pageBtnPrev = " ";
let pageBtnNext = " ";
let pageTips = "" + PageIndex + " " + "-" + " " + totalPage + " " + "of" + " " + total + " " + "items" + "
评论列表(0条)