找不到模块:无法解析 'react-pagination'
Module not found: Can't resolve 'react-pagination'
我已经使用以下命令安装了 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>
回答将不胜感激!
您需要安装react-pagination:
npm install react-bootstrap bootstrap
并像这样导入:
import Pagination from 'react-bootstrap/Pagination'
问题出在包文档上,因为导入说明不正确here at official page。
import Pagination from 'react-pagination';
上面的导入语句应该是
import Pagination from "react-bootstrap-4-pagination";
但在 codesandbox.io 此处 code for live demo provided in official docs
的软件包官方页面提供的现场演示中说明正确
我已经使用以下命令安装了 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>
回答将不胜感激!
您需要安装react-pagination:
npm install react-bootstrap bootstrap
并像这样导入:
import Pagination from 'react-bootstrap/Pagination'
问题出在包文档上,因为导入说明不正确here at official page。
import Pagination from 'react-pagination';
上面的导入语句应该是
import Pagination from "react-bootstrap-4-pagination";
但在 codesandbox.io 此处 code for live demo provided in official docs
的软件包官方页面提供的现场演示中说明正确