Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css React引导元素没有样式_Css_Twitter Bootstrap_Reactjs_Webpack_React Bootstrap - Fatal编程技术网

Css React引导元素没有样式

Css React引导元素没有样式,css,twitter-bootstrap,reactjs,webpack,react-bootstrap,Css,Twitter Bootstrap,Reactjs,Webpack,React Bootstrap,我正在使用react.js和react路由器和webpack开发一个webapp。 我想使用react引导设置样式,但我的导航栏似乎没有如图所示设置样式 这是我的react引导代码 <Navbar inverse fixedTop> <Navbar.Collapse> <Nav bsStyle="pills"> <NavItem

我正在使用react.js和react路由器和webpack开发一个webapp。 我想使用react引导设置样式,但我的导航栏似乎没有如图所示设置样式

这是我的react引导代码

<Navbar inverse fixedTop>
            
            <Navbar.Collapse>
            <Nav bsStyle="pills">
              <NavItem  href="#"><Link to="/">{this.state.navMenu[0] }</Link></NavItem>
              <NavItem  href="#"><Link to="/utilities">{this.state.navMenu[3] }</Link></NavItem>
              <NavItem  href="#"><Link to="/main">{this.state.navMenu[4] }</Link></NavItem>
            </Nav>             
            </Navbar.Collapse>
          </Navbar>
这是webpack.config文件

var webpack = require('webpack');  
module.exports = {  
    entry: [
      'babel-polyfill',
      'webpack/hot/only-dev-server',
      "./app.js",
    ],
    output: {
        path: __dirname + '/build',
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.jsx?$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/},
            { test: [/\.jsx?$/, /\.es6$/], exclude: /node_modules/, loader: 'babel-loader'  },
            { test: /\.css$/, loader: 'style!css' },
        ]
    },
     resolve: {
    // you can now require('file') instead of require('file.coffee')
    extensions: ['', '.js', '.json', '.coffee'] 
    },
    plugins: [
      new webpack.NoErrorsPlugin(),
      
    ]

};
我试图要求“引导”,但我得到以下错误:未捕获引用错误:未定义jQuery


非常感谢您的帮助。

您不应该包含引导,因为它将在您的项目中包含所有引导js文件(它们作为依赖项jquery-因此您会遇到错误)。您不需要引导js文件,因为您使用的是react引导

要包含引导写入中的所有css文件,请执行以下操作:

import style from 'bootstrap/dist/css/bootstrap.css';
之后,您还将遇到其他装载机的问题。这是因为,引导样式也使用其他文件

安装:

npm install --save-dev url-loader
您必须添加到网页包配置加载程序:

{
  test: /\.(png|woff|woff2|eot|ttf|svg)$/,
  loader: 'url-loader?limit=100000'
},
在样式加载器文档页面中,作者建议将样式加载器与css加载器一起使用。更改此项:

{ test: /\.css$/, loader: 'style!css' },

一些人可能会发现一个有用的更新:确保您安装了bootstrap v3.3.7(npm安装--保存)bootstrap@3.3.7)而不是最新的版本4,因为react引导以v3中的CSS为目标。许多样式(例如导航栏样式)在v4的CSS中不存在。

“jQuery未定义”错误表示jQuery丢失,是否链接?非常感谢!这对我有用。我非常感谢你。
{ test: /\.css$/, loader: 'style!css' },