![](/img/trans.png)
[英]React-router-dom not rendering component and Getting error GET http://localhost:8080/editor 404 (Not Found)
[英]Why getting 404 when try to get page via react-router-dom?
嘗試通過 url /items/best
獲得 404 。 為什么會發生? 我使用 react-router-dom
<Router history={history}>
<Switch>
<Route exact path="/items" component={Items} />
<Route exact path="/items/best" component={BestItems} />
<Route exact path="/login" component={Login} />
<Redirect from="*" to="/login" />
</Switch>
</Router>
最后在 webpack 配置中添加跟隨設置幫助了我:
output: {
publicPath: "/",
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.