@ngxs/storage-plugin
与@ngxs/router-plugin
导致路由中断一起使用。如果我删除其中任何一个路由工作正常。对于它们,如果我在浏览器中键入 URL,它总是返回到最后一个路由。我尝试更改这些插件的加载顺序(将 storage-plugin 移至最后),行为是相同的。
我的app.routes.ts
模块中有以下路线。
export const routes: Route[] = [
{
path: 'login',
children: AUTH_ROUTES
},
{
path: 'account-verification',
loadChildren: 'app/account-verification/account-verification.module#AccountVerificationModule'
},
{
path: 'profile',
loadChildren: 'app/profile/profile.module#ProfileModule'
},
{
path: '',
component: LayoutComponent,
children: [
{ path: '', loadChildren: 'app/user-dashboard/user-dashboard.module#UserDashboardModule' },
{ path: 'calendar', loadChildren: 'app/calendar/calendar.module#CalendarModule' },
// { path: 'messages', loadChildren: 'app/messaging/messaging.module#MessagingModule' },
],
canActivate: [ guards.AuthGuard, guards.AccountVerificationGuard ]
}
];
我可以毫无问题地从/profile/create
(ProfileModule 中的子路由)导航到login
。
单击按钮转到使用的路线[routerLink]
仍然有效,但如果我打开/profile/create
并/login
在浏览器中输入,我会立即返回到/profile/create
. 这是我的进口app.module.ts
:
imports: [
BrowserModule,
AuthModule,
CoreModule,
HttpClientModule,
LayoutModule,
AngularFontAwesomeModule,
RouterModule.forRoot(routes, { enableTracing: true }),
NgxsModule.forRoot([]),
NgxsReduxDevtoolsPluginModule.forRoot(),
NgxsStoragePluginModule.forRoot(),
NgxsRouterPluginModule.forRoot(),
ToastrModule.forRoot({
timeOut: 10000,
positionClass: 'toast-top-right',
preventDuplicates: true,
}),
ToastContainerModule,
BrowserAnimationsModule,
FileUploadModule
],
包.json
"dependencies": {
"@angular/animations": "6.0.4",
"@angular/cdk": "6.2.1",
"@angular/common": "6.0.4",
"@angular/compiler": "6.0.4",
"@angular/core": "6.0.4",
"@angular/forms": "6.0.4",
"@angular/http": "6.0.4",
"@angular/material": "6.2.1",
"@angular/platform-browser": "6.0.4",
"@angular/platform-browser-dynamic": "6.0.4",
"@angular/router": "6.0.4",
"@ngxs/router-plugin": "3.1.3",
"@ngxs/storage-plugin": "3.1.3",
"@ngxs/store": "3.1.3",