【问题标题】:How to add routing on Material UI Icon using v6 router如何使用 v6 路由器在 Material UI Icon 上添加路由
【发布时间】:2022-01-15 01:52:39
【问题描述】:

我有联系人列表,每个都有编辑图标,我想在点击编辑图标时路由到编辑组件,我尝试将图标作为链接组件,如下所示:

<ModeEdit component={Link} to={{`contact/edit/${contact.id}`}} state:{contact} style={{ color: 'blue', marginRight: '10px' }} ></ModeEdit>

没用

我想通过路由将对象传递给使用功能组件的编辑组件

【问题讨论】:

    标签: reactjs react-router


    【解决方案1】:

    如果有必要,不要忘记在路径中以'/'开头(这里你有相对路径):

    <Link to={{`contact/edit/${contact.id}`}}>
      <ModeEditIcon style={{ color: 'blue', marginRight: '10px' }} />
    </Link>

    【讨论】:

      猜你喜欢
      • 2020-08-12
      • 2018-04-04
      • 2021-03-29
      • 2018-11-20
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 2022-06-15
      • 2018-07-05
      相关资源
      最近更新 更多