0

我已经使用以下命令安装了 react-pagination:-

npm i react-bootstrap-4-pagination

我的代码:-

import React, { Component } from "react";
import { Link } from "react-router-dom";

import Pagination from 'react-pagination';


let paginationConfig = {
  totalPages: 22,
  currentPage: 15,
  showMax: 5,
  size: "lg",
  threeDots: true,
  prevNext: true,
  href: 'https://example.com/items?page=*', // * will be replaced by the page number
  pageOneHref: 'https://example.com/items',
  borderColor: 'red',
  activeBorderColor: 'black',
  activeBgColor: 'grey',
  disabledBgColor: 'red',
  activeColor: 'red',
  color: 'purple',
  disabledColor: 'green',
  circle: true,
  shadow: true
};




   <Pagination
        threeDots
        totalPages={22}
        currentPage={15}
        showMax={7}
        prevNext
        activeBgColor="#18eaca"
        activeBorderColor="#7bc9c9"
      />
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

答案将不胜感激!

4

2 回答 2

2

问题出在包文档上,因为官方页面上的导入说明不正确。

import Pagination from 'react-pagination';

上面的导入语句应该是

import Pagination from "react-bootstrap-4-pagination";

但是在codesandbox.io的包官方页面提供的现场演示中正确说明了官方文档中提供的现场演示代码

于 2021-01-04T21:09:27.797 回答
0

您需要安装反应分页:

npm install react-bootstrap bootstrap

并像这样导入:

import Pagination from 'react-bootstrap/Pagination'
于 2021-01-04T20:51:50.780 回答