【问题标题】:What is the difference between (replace & <Redirect /> ) in React RouterReact Router 中的 (replace 和 <Redirect /> ) 有什么区别
【发布时间】:2021-11-10 03:58:15
【问题描述】:

在 react-router(重定向)和 props.history.replace 中 他们在做同样的过程,当我按下返回页面时,我没有得到上一页,它们都是一样的,为了解决这个问题,我使用 push ,但为什么它们是一样的(替换 & )

【问题讨论】:

    标签: reactjs react-router


    【解决方案1】:

    将历史视为Stack 数据结构。

    TDLR栈是如何工作的以及push和replace的区别

    const history = ['/login']
    // history.push("/dashboard") ['/login', '/dashboard']
    // history.replace('/dashboard') ['/dashboard']
    // history.pop() []
    

    【讨论】:

      猜你喜欢
      • 2023-03-24
      • 2018-07-16
      • 2019-11-07
      • 2017-08-28
      • 2022-12-13
      • 2019-04-29
      • 2012-04-28
      • 2019-02-19
      • 1970-01-01
      相关资源
      最近更新 更多