React中的内联样式CSS无效

时间:2017-09-07 04:00:27

标签: reactjs

我不知道为什么我的内联css不能在这里工作。您可以在<div className="navbar-nav" style={background-color: red}>上看到它。任何帮助将是欣赏。提前致谢。

完整代码

import React from 'react';
import {
  BrowserRouter,
  Route,
  Link
} from 'react-router-dom';

const HeaderWrapper = () => (
    <div>
        <nav className="navbar navbar-expand-lg navbar-dark bg-dark">
          <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
            <span className="navbar-toggler-icon"></span>
          </button>
          <div className="collapse navbar-collapse" id="navbarNavAltMarkup">
            <div className="navbar-nav" style={background-color: red}>
              <Link className="nav-item nav-link active" to="/">Home <span className="sr-only">(current)</span></Link>
              <Link className="nav-item nav-link" to="/about">About Us</Link>
              <Link className="nav-item nav-link" to="/">Whats New</Link>
              <Link className="nav-item nav-link" to="/">Designers</Link>
              <Link className="nav-item nav-link" to="/">Clothing</Link>
              <Link className="nav-item nav-link" to="/">Accessories</Link>
              <Link className="nav-item nav-link" to="/">How it Works</Link>
              <Link className="nav-item nav-link" to="/">Magazine</Link>
            </div>
          </div>
        </nav>
    </div>
)

export default HeaderWrapper

1 个答案:

答案 0 :(得分:1)

尝试:

<div className="navbar-nav" style={{ backgroundColor: 'red' }}>