此錯誤是由配置錯誤、版本不匹配或引導安裝損壞引起的。如果已經安裝了引導程序和反應引導程序,則可以通過以下方式進行更改:
npm install --save bootstrap@^4.0.0-alpha.6 react-bootstrap@^0.32.1
(檢查package.json是否包含“bootstrap”和“react bootstrap”(如果不確定),只需安裝不同版本的bootstrap並重新構建項目。它應該替換或添加該文件(bootstrap/dist/css/bootstrap theme.css)到該文件夾中。根據我的create react app generated readme.md中的建議,引導程序的較低版本對我有效:
npm install --save react-bootstrap bootstrap@3
Adding Bootstrap
You don’t have to use React Bootstrap together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps:
Install React Bootstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well:
sh npm install --save react-bootstrap bootstrap@3
Alternatively you may use
yarn
:
sh yarn add react-bootstrap bootstrap@3