【发布时间】:2021-02-07 19:12:45
【问题描述】:
我已经让 React Router 正常工作了 年。现在突然今天早上它停止工作了。我正在使用 React Router 5。
我创建了一个小型演示项目来演示异常情况。这是路由器:
import React from 'react'
import {Route, Router, Switch} from 'react-router';
import {Link} from 'react-router-dom'
import History from 'history';
const browserHistory = History.createBrowserHistory();
console.log(browserHistory.location);
export function App() {
return (
<Router history={browserHistory}>
<Switch>
<Route path="/" render={(routeProps) =>
<Link to={"/"}>Home</Link>
}/>
<Route render={(routeProps) =>
<Link to={"/"}>It's the same location ("/"). Why did I go to a different route?</Link>
}/>
</Switch>
</Router>
)
}
点击“主页”,应该会重新显示主页...但它没有。
Here's a dropbox link to download the tiny demo app。 Meteor 是构建工具,所以要运行它:
meteor npm installmeteor run- 查看应用程序
http://localhost:3000/
我错过了什么?
【问题讨论】:
标签: reactjs meteor react-router