简体   繁体   English

React组件样式化方法

[英]React components styling methods

I have this following component - 我有以下组件-

import React from 'react';
import {Route, Link} from 'react-router-dom'
import Error from './Error'

class NavigationBar extends React.Component {
    render() {
        return (
            <div className="nav">
                <nav className="navbar navbar-inverse bg-inverse">
                    <ul className="nav navbar-nav">
                        <li className="nav-item">
                            <Link to={"/data"} className="nav-link"> Data </Link>
                        </li>
                        <li className="nav-item">
                            <Link to={"/analysis"} className="nav-link"> Analysis </Link>
                        </li>
                        <li className="nav-item">
                            <Link to={"/Monitor"} className="nav-link"> Monitor </Link>
                        </li>
                    </ul>
                </nav>
                <Route path={"/webiks/:user"} component={Error}/>
            </div>
        );
    }
}

export default NavigationBar;

In addition i added a nav.css file to index.html in order to make some changes to the boostrap styling. 另外,我在index.html中添加了一个nav.css文件,以便对boostrap样式进行一些更改。

The problem is that when entering the "webkis/:user" url the style only boostrap styling without the changes of the nav.css file. 问题在于,当输入“ webkis /:user” URL时,样式仅是boostrap样式,而没有更改nav.css文件。 If one can explaing the reason , and also to mention some of the common methods for styling components (which is NOT an inline styling). 如果可以解释原因,还可以提及一些用于样式化组件的常用方法(不是内联样式化)。

Thanks. 谢谢。

将nav.css与NavigationBar.js放在同一文件夹中,然后在导入列表中添加以下行: import './nav.css'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM