加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – React-Bootstrap中NavDropdown中的EventKeys

发布时间:2020-12-15 20:20:43 所属栏目:百科 来源:网络整理
导读:我在NavDropdowns中遇到了eventKey问题. var Navigation = React.createClass({ handleSelect: function(eventKey){ console.log(eventKey); },render: function() { return ( Navbar brand='Navbar' toggleNavKey={0} CollapsibleNav eventKey={0} onSelect
我在NavDropdowns中遇到了eventKey问题.

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之外的所有元素:

单击Dropdown不会触发selectHandler,这很好.
但是,当我单击其中一个MenuItem,而不是给我一个eventKey时,它给了我一个事件对象.

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

编辑:我的版本是:

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

解决方法

这是react-bootstrap中的一个错误

https://github.com/react-bootstrap/react-bootstrap/issues/1268

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读