我正在尝试使用react-bootstrap来设计网页样式。
package.json
{
"name": "chrome-ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-scripts": "1.0.16"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"react-bootstrap": "^0.31.5"
}
}
App.js
import React from 'react';
import { Button } from 'react-bootstrap'
function CheckState(props){
function handleClick(e){
console.log(props.state)
}
return(
<Button bsStyle="primary" onClick={handleClick}>Click for state</Button>
)
}
但是,当我刷新时,在网页上看到的是:
看起来不像是在添加样式。我做错了什么?
2条答案
按热度按时间2exbekwf1#
添加导入“bootstrap/dist/css/bootstrap.css”;在index.js中
68bkxrlz2#
在react应用程序中,打开index.js文件并添加
import 'bootstrap/dist/css/bootstrap.css';