【发布时间】:2020-10-14 22:49:13
【问题描述】:
在运行我使用 react-bootstrap-table2-paginator 的项目时出现以下错误。但是我已经安装了模块,请看下图...
./node_modules/react-bootstrap-table2-paginator/lib/src/pagination.js
Module not found: Can't resolve 'classnames' in '/home/edu/pagination/node_modules/react-bootstrap-table2-paginator/lib/src'
我的app.js文件如下:
import React, { Component } from 'react';
import BootstrapTable from 'react-bootstrap-table-next';
import paginationFactory from 'react-bootstrap-table2-paginator';
const dataMovie = [{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' },
{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' },
{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' },
{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' } ];
const columns = [
{
datafield : 'id',
text: 'ID'
},
{
datafield:'title',
name: 'Title',
},
{
datafield: 'Year',
name: 'year',
},
];
class App extends Component {
render() {
return (
<BootstrapTable keyField='id' data={ dataMovie } columns={ columns } pagination={ paginationFactory() } />
)
}
};
export default App;
package.json 中的依赖项
"react": "^16.13.1",
"react-bootstrap-table2-paginator": "^2.1.2",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
我已经使用流动命令安装了 react-bootstrap-table2-paginator
npm install react-bootstrap-table2-paginator --save
【问题讨论】:
-
我这边没有收到这个错误
标签: reactjs pagination