通过延迟加载加载了错误的模块

时间:2018-07-30 08:26:58

标签: typescript angular5 angular-routing

这是我的应用路由结构:

export const AppRoutes: Routes = [
{
    path: '',
    redirectTo: 'project',
    pathMatch: 'full',
}, {
    path: '',
    component: AdminLayoutComponent, canActivate: [Authguard],
    children: [
        {
            path: 'project',
            loadChildren: 'app/projectTable/projectTable.module#ProjectTableModule'
        },
        {
            path: 'wizard',
            loadChildren: 'app/wizard/wizard.module#WizardModule'
        },
        {
            path: 'workflows',
            loadChildren: 'app/workflows/workflows.module#WorkflowsModule'
        },
        {
            path: 'setup',
            loadChildren: 'app/setup/setup.module#SetupModule'
        }
    ]
},
{
    path: '',
    component: AuthLayoutComponent, canActivate: [Anonguard],
    children: [{
        path: 'login',
        loadChildren: './pages/pages.module#PagesModule'
    }]
}
];

每当我单击设置选项卡时,都会加载projectTable模块。我不知道我在做什么错。如果答案是显而易见的,请原谅我,因为我仍然是初学者。 该图显示正在为设置模块加载2条路由。

enter image description here

1 个答案:

答案 0 :(得分:1)

仅出于建议,您正在提及自己的路线。 项目的默认路径,然后仅在问题所在的项目模块中导航。

import { applyMiddleware, compose, createStore } from 'redux'

import reduxOfflineThunkMiddleware from './thunk-middleware'
import rootReducer from '../../reducers'

import { createUser } from '../../actions/user'

const initialState = {}

const windowCompose = (typeof window !== 'undefined') && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
const composeEnhancers = windowCompose || compose

const store = createStore(
  rootReducer,
  initialState,
  composeEnhancers(
    applyMiddleware(reduxOfflineThunkMiddleware({ createUser })),
    offline()
  )
)

我相信您的代码有误。

如果您提供要尝试导航的网址 SetupModule 。我是说'/ setup'还是其他名称?

还提供SetupModule代码。