2016-03-31 44 views
0

这与Make Twitter Bootstrap navbar work like tabs有关但我试图让它在React中工作。 基本上,我希望制表符在导航栏中显示。有没有简单的方法来做到这一点?
http://react-bootstrap.github.io/components.html#navigationReact Bootstrap中的标签Navbar

<Navbar> 
    <Navbar.Header> 
    <Navbar.Brand> 
     <a href="#">React-Bootstrap</a> 
    </Navbar.Brand> 
    </Navbar.Header> 
    <Nav> 
    <NavItem eventKey={1} href="#">Link</NavItem> 
    <NavItem eventKey={2} href="#">Link</NavItem> 
    </Nav> 
</Navbar> 

代替NavItem的,我可以用 <Tab eventKey={1} title="Tab 1">Tab 1 content</Tab>

回答

0

只需使用

constructor(state) { 
     super(state); 
     this.state = { 
      activeKey: 1 
     }; 
    } 

    handleSelect(eventKey) { 
     this.setState({ 
      activeKey: eventKey 
     }); 
    } 

render() { 

     <Nav bsStyle="tabs" activeKey={this.state.activeKey} 
     onSelect={this.handleSelect.bind(this)}> 

     <...> 
     } 

,而不是<Nav>,它会做的工作。 Docs