react组件上的UI。我有一个<BottomNavigationItem />组件。这实际上呈现为一个<button>。我如何才能真正让它呈现/导航到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>
);
}
}发布于 2018-02-01 15:28:34
你可以简单地添加containerElement={<Link to="/home"/>},别忘了从react-router-dom导入Link
因此,它将是这样的:
<BottomNavigationItem
containerElement={<Link to="/home"/>}
label="Reviews"
icon={reviewIcon}
onClick={() => this.select(0)}
/>https://stackoverflow.com/questions/46759898
复制相似问题