Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.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
Javascript ReactJS:NavBar_Javascript_Reactjs - Fatal编程技术网

Javascript ReactJS:NavBar

Javascript ReactJS:NavBar,javascript,reactjs,Javascript,Reactjs,我试图在导航栏中认识到改变语言的可能性。我已使用此代码: <div className="nav-mobile"> <div className="link-list-wrapper collapse" id="menu1"> <nav> <ul className="link-list"> <li><a classNa

我试图在导航栏中认识到改变语言的可能性。我已使用此代码:

<div className="nav-mobile">
        <div className="link-list-wrapper collapse" id="menu1">
          <nav>
                  <ul className="link-list">
                    <li><a className="list-item " onClick={this.changeLan.bind(this, this.ita)}>ITA</a></li>
                    <li><a className="list-item " onClick={this.changeLan.bind(this, this.eng)}>ENG</a></li>
                  </ul>
          </nav>
        </div>
      </div>

但是我只想“激活”按钮,而不是像代码中那样总是激活的

  • 你知道为什么当我把鼠标放在链接上时,链接是这样出现的吗?因为它不是一个链接

  • 假设在
    this.changeLan
    中,您将属性
    this.active
    更改为
    this.ita
    this.eng
    : 你可以试试

  • 伊塔
  • 英格

  • 假设在
    this.changeLan
    中,您将属性
    this.active
    更改为
    this.ita
    this.eng
    : 你可以试试

  • 伊塔
  • 英格
  • 为您选择的语言名称创建一个状态,例如it
    lang
    const{lang}=this.state
    ...
    
  • 伊塔
  • 英格
  • 然后您只需要为类
    active
    对于第二个问题,更改li标记的
    悬停
    css

    为所选语言名称创建一个状态,例如it
    lang
    const{lang}=this.state
    ...
    
  • 伊塔
  • 英格
  • 然后您只需要为类
    active

    对于第二个问题,请更改li标签的
    悬停
    css

    是否可以添加react代码。因为它需要状态。请添加react代码。因为它需要国家。
              <li><a class="list-item" href="#">Link 1</a></li>
              <li><a class="list-item active" href="#">Link 2 Active</a></li>