angular - Angular 默认路由器插座
问题描述
我有用户模块,我正在尝试加载默认路由器插座。当路径为 /user 但它不起作用时,我想加载 UserHomeComponent 。如果我添加路径而不是将其保持为空,则它可以正常工作。这是我的用户路由模块:
const routes:Routes = [
{path: 'user' , component: UserComponent , children:[
{path: '' , component: UserHomeComponent},
{path: 'new-request' , component: NewRequestComponent},
{path: 'checkout' , component: CheckoutComponent},
{path: 'edit-info' , component: UserEditInfoComponent},
{path: 'requests', component: UserRequestsComponent},
{path: 'change-password' , component: UserChangePasswordComponent},
{path: 'delete-account' , component: DeleteAccountComponent}
]}
]
这是我的应用路由模块:
const appRoutes:Routes = [
{path: '' , redirectTo: 'login' , pathMatch: 'full'},
{path: 'login' , component: LoginComponent },
{path: 'signup' , component: SignupComponent},
{path: 'user' , loadChildren: () => import('./user/user.module').then(m => m.userModule)},];
解决方案
加载一个 UserHomeComponent,改变这个
{path: 'user' , component: UserComponent , children:[
经过
{path: '' , component: UserComponent , children:[
推荐阅读
- python - 句子包含python中的确切单词
- java - 使用 pdfbox 2.0.12 java 进行多重设计?
- java - 使用 Retrofit 2 获取和获取未知数据集
- javascript - 使用 Http 和 Secure 将 Jwt 令牌存储在 Cookie 中,而不是 Javascript 中的 LocalStorage
- java - 从 RealmList 查询
在 RealmObject 中 - ruby-on-rails - Rspec给出错误的结果
- python - 有没有办法通过python反序列化java对象?
- django - 如何在 Django 表单中获取当前 URL?
- python - 如何从 js 文件与 Heroku 交互
- sql-server - 使用循环或数组将数据从一个表插入到另一个 sql