簡體   English   中英

為什么在嘗試通過 react-router-dom 獲取頁面時得到 404?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM