我想知道如何在react-router-dom v6中使用单个容器或布局实现多个路由
到目前为止,这是我的代码:
<Routes>
<Route
path="/dashboard"
element={
<AdminLayout>
<DashboardScreen />
</AdminLayout>
}
/>
<Route
path="/guides"
element={
<AdminLayout>
<GuidesScreen />
</AdminLayout>
}
/>
<Route
path="/post"
element={
<AdminLayout>
<PostScreen />
</AdminLayout>
}
/>
</Routes>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我在这里错过了什么?
谢谢!
代码更新:
<Routes>
<LoginLayout>
<Route path="/" element={<SignInForm />} />
<Route path="/signin" element={<SignInForm />} />
<Route path="/newpassword" element={<NewPassword />} />
<Route path="/phoneverification" element={<PhoneVerification />} />
<Route path="/continuewithphone" element={<ContWithPhone />} />
<Route path="/resetpassword" element={<ResetPassword />} />
<Route
path="/confirm-resetpassword"
element={<ConfirmResetPassword />}
/>
</LoginLayout>
</Routes>
<Routes>
<AdminLayout>
//Routes here
</AdminLayout>
</Routes> …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我已将查询参数设置为可选,但它没有反映 swagger 中的可选,
这是我的代码:
@Get('pagination')
@ApiOperation({ summary: 'Get Activity Post Pagination Enabled' })
public async getActivityPostPagination(
@Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number,
@Query('limit', new DefaultValuePipe(10), ParseIntPipe) limit: number,
@Query('user_id') user_id?: string,
@Query('badge_id') badge_id?: string,
@Query('title') title?: string,
) {
//code here
}
Run Code Online (Sandbox Code Playgroud)
但很招摇,它显示如下:
page 和 limit 不是可选的,但对于其他查询参数必须是可选的,我在这里缺少什么?
谢谢