【问题标题】:<link> changes the route in the browser address bar but nothing changes<link> 更改浏览器地址栏中的路由但没有任何变化
【发布时间】:2020-04-06 12:30:40
【问题描述】:

我正在使用 react 路由器浏览我的 react 应用程序。当我点击链接时,浏览器地址栏中的地址会发生变化,但新组件不会呈现

【问题讨论】:

标签: reactjs react-router react-router-v4 react-router-dom


【解决方案1】:

我认为作为一种解决方法,您可以将应用中的链接转换为按钮链接,并在其 onClick 功能中使用 Redirect from react router 来强制更改您的路线,因此您的代码如下:

import { Redirect } from "react-router-dom";
handleNewRoute(){
    <Redirect to={this.state.redirectLink} />
}
猜你喜欢
  • 2016-03-25
  • 2011-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-21
  • 2012-03-18
相关资源
最近更新 更多