延迟加载模块时无法获取文件
Cannot get files when lazy loading a module
我试图在我的 angular 2 应用程序上延迟加载一些模块,但是当我转到特定模块的路由时,GET 请求似乎搞砸了。
应用-routing.module.ts
const routes = [
{path: 'products', loadChildren: './products/products.module#ProductsModule'},
{path: 'user', loadChildren: './user/user.module#UserModule'},
{path: '**', redirectTo: '/products'}
]
产品-routing.module.ts
const routes: Routes = [
{path: '', component: ProductsComponent}
];
用户-routing.module.ts
const routes: Routes = [
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'reset-password', component: ResetPasswordComponent},
{path: 'profile', component: ProfileComponent}
];
产品路线完美运行,但用户路线似乎不起作用,我认为这是由于以下控制台错误造成的:
GET http://localhost:4200/user/inline.bundle.js net::ERR_ABORTED
出于某种原因,用户被添加到 url 中以获取我的所有资产。我猜我在路由方面做错了什么,但我不完全确定是什么?
用户模块中是否有 ''
空路径?您应该为您的用户模块创建一些重定向空传递,因为当 UserModule 被延迟加载时您的路径位于 /user/
,并且没有到它的路由。
用户-routing.module.ts
const routes: Routes = [
{path: '', redirectTo: 'login', pathMatch: 'full'},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'reset-password', component: ResetPasswordComponent},
{path: 'profile', component: ProfileComponent}
];
我试图在我的 angular 2 应用程序上延迟加载一些模块,但是当我转到特定模块的路由时,GET 请求似乎搞砸了。
应用-routing.module.ts
const routes = [
{path: 'products', loadChildren: './products/products.module#ProductsModule'},
{path: 'user', loadChildren: './user/user.module#UserModule'},
{path: '**', redirectTo: '/products'}
]
产品-routing.module.ts
const routes: Routes = [
{path: '', component: ProductsComponent}
];
用户-routing.module.ts
const routes: Routes = [
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'reset-password', component: ResetPasswordComponent},
{path: 'profile', component: ProfileComponent}
];
产品路线完美运行,但用户路线似乎不起作用,我认为这是由于以下控制台错误造成的:
GET http://localhost:4200/user/inline.bundle.js net::ERR_ABORTED
出于某种原因,用户被添加到 url 中以获取我的所有资产。我猜我在路由方面做错了什么,但我不完全确定是什么?
用户模块中是否有 ''
空路径?您应该为您的用户模块创建一些重定向空传递,因为当 UserModule 被延迟加载时您的路径位于 /user/
,并且没有到它的路由。
用户-routing.module.ts
const routes: Routes = [
{path: '', redirectTo: 'login', pathMatch: 'full'},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'reset-password', component: ResetPasswordComponent},
{path: 'profile', component: ProfileComponent}
];