【问题标题】:Material-UI BottomNavigationItem URLMaterial-UI 底部导航项 URL
【发布时间】:2017-10-15 20:54:12
【问题描述】:

反应组件上的 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>
    );
  }
}

【问题讨论】:

    标签: javascript reactjs typescript material-design material-ui


    【解决方案1】:

    只需添加containerElement={&lt;Link to="/home"/&gt;},别忘了从react-router-dom 导入Link

    所以它会是这样的:

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

    【讨论】:

      猜你喜欢
      • 2019-06-19
      • 2019-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 2021-03-16
      相关资源
      最近更新 更多