2017-10-15 24 views
0

反应组件上的UI。我有一个<BottomNavigationItem />组件。这实际上呈现为<button>。我怎样才能让它呈现/导航到一个URL?Material-UI BottomNavigationItem URL

class FooterNavigation extends Component { 
    state = { 
    selectedIndex: 0, 
    }; 

    select = (index) => this.setState({selectedIndex: index}); 

    render() { 
    return (
     <footer className="mdl-mini-footer"> 
      <Paper zDepth={1}> 
      <BottomNavigation selectedIndex={this.state.selectedIndex}> 
      <BottomNavigationItem 
       label="Reviews" 
       icon={reviewIcon} 
       onClick={() => this.select(0)} 
      /> 
      </BottomNavigation> 
      </Paper> 
     </footer> 
    ); 
    } 
} 

回答

0

简单的,你可以再补充containerElement={<Link to="/home"/>}不要忘了从react-router-dom

导入Link因此,这将是这样的:

<BottomNavigationItem 
       containerElement={<Link to="/home"/>} 
       label="Reviews" 
       icon={reviewIcon} 
       onClick={() => this.select(0)} 
      />