reactjs - react-bootstrap 没有按预期工作

标签 reactjs react-bootstrap

我正在尝试使用 react-bootstrap 来设计网页样式。

包.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"
  }
}

应用程序.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>
    )
}

但是,这是我刷新时在网页上看到的内容:

enter image description here

它看起来不像正在添加样式。我究竟做错了什么?

最佳答案

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

关于reactjs - react-bootstrap 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47062703/

相关文章:

android - 如何上传React-native 0.54.3 Android Apk到商店?它引发Google Play 64位要求错误

javascript - react native 相机胶卷 "null is not an object (evaluating ' this.state.photos')"

javascript - 如何在 React 路由器上使用 Laravel 路由

reactjs - 当我通过列表映射时,React-bootstrap Modal 组件打开/关闭所有模式

reactjs - 如何将 React bootstrap NavBar 向左对齐

javascript - 如何在react中向子函数提供参数?

javascript - 如何向警报添加 URL 链接?

javascript - React-Bootstrap 和 Bootstrap-sass modal.scss 未加载

css - 使用react-bootstrap在一定高度后切断内容

jquery - 从 create-react-app 项目中排除 Webpack 的依赖项