React-Bootstrap 中 NavDropdown 中的事件键 [英] EventKeys in NavDropdown in React-Bootstrap

查看:31
本文介绍了React-Bootstrap 中 NavDropdown 中的事件键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 NavDropdowns 中的 eventKey 有问题.

I have a problem with the eventKey thing in NavDropdowns.

var Navigation = React.createClass({

  handleSelect: function(eventKey){
    console.log(eventKey);
  },

  render: function() {
    return (
      <Navbar brand='Navbar' toggleNavKey={0}>
        <CollapsibleNav eventKey={0} onSelect={this.handleSelect}>

          <Nav navbar>
            <NavItem eventKey={1}>Home</NavItem>
          </Nav> 


          <Nav navbar right hide>
            <NavItem eventKey={2}>Login</NavItem>

            <NavDropdown eventKey={3} title='NavDropdown' id='basic-nav-dropdown'>
              <MenuItem eventKey={4}>Action 1</MenuItem>
              <MenuItem eventKey={5}>Action 2</MenuItem>
            </NavDropdown>
          </Nav>

        </CollapsibleNav>
      </Navbar>

    )
  }
});

我希望能够在我的 selectHandler 中判断点击了哪个 Nav 元素.这适用于除 NavDropdown 之外的所有元素:

I want to be able in my selectHandler to tell what Nav element was clicked. This works great for all elements except the NavDropdown:

点击Dropdown不会触发selectHandler,这很好.但是当我单击 MenuItem 之一时,它没有给我 eventKey,而是给我一个 event 对象.

Clicking the Dropdown does not trigger the selectHandler, which is fine. But when I click one of the MenuItem, instead of giving me the eventKey, it gives me an event object.

如何修改 NavDropdown 以便它为我提供 eventKey?

How can I modify the NavDropdown so that it gives me the eventKey?

我的版本是:

"react": "^0.14.0-beta3",
"react-bootstrap": "^0.25.100-react-pre.0",

推荐答案

这是 react-bootstrap 的一个 bug

It is a bug in react-bootstrap

https://github.com/react-bootstrap/react-bootstrap/问题/1268

这篇关于React-Bootstrap 中 NavDropdown 中的事件键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆