reactjs react-bootstrap未按预期工作

rvpgvaaj  于 2022-11-29  发布在  React
关注(0)|答案(2)|浏览(159)

我正在尝试使用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>
    )
}

但是,当我刷新时,在网页上看到的是:

看起来不像是在添加样式。我做错了什么?

2exbekwf

2exbekwf1#

添加导入“bootstrap/dist/css/bootstrap.css”;在index.js中

68bkxrlz

68bkxrlz2#

在react应用程序中,打开index.js文件并添加import 'bootstrap/dist/css/bootstrap.css';

相关问题