【发布时间】:2021-11-13 06:23:53
【问题描述】:
我使用带有指定版本的以下依赖项的反应
{
"react-router-dom": "^5.2.0",
"react-dom": "^16.14.0",
}
我想要这样的路线
- 首页
- 关于
- 首页/测试
- Home/Test/New
我有
<BrowserRouter>
<Switch>
<PublicRoute component={Login} path="/" exact />
<PublicRoute component={Login} path="/login" exact />
<PrivateRoute component={Dashboard} path="/dashboard"/>
<Route to="/404" component={NotFound} />
</Switch>
</BrowserRouter>
在仪表板上我有这个
<Router>
<Navbar />
<Switch>
<Route path={`/dashboard/buyList`} component={BuyList} />
<Route exact path='/dashboard/buyList/new' component={NewBuy} />
<Route path={`/dashboard/buyList${ids.id}`} component={BuyInfo}/>
<Route path='/dashboard/showAddress' component={ShowAddress} exact/>
<Route path='/dashboard/qrScanner' component={QrScanner} exact/>
<Route path='/dashboard/productList' component={ProductList} exact/>
<Route path='/dashboard/productListCode' component={ProductListCode} exact/>
<Route path='/dashboard/deliveryScanner' component={DeliveryScanner} exact/>
<Route path='/dashboard' component={DashboardDetail} exact/>
<Route path="/404" component={NotFound} />
</Switch>
</Router>
但在"/dashboard/buyList/new" 中正在加载"/dashboard/buyList" 的组件
【问题讨论】:
标签: reactjs react-router react-router-dom