我想添加一个新的AsyncRoute。但是有一个例外
export const routes: RouterConfig = [
{ path: 'detail', component: 'Detail', canActivate: [ WebpackAsyncRoute ] },
{ path: 'foo', component: 'Foo', canActivate: [ WebpackAsyncRoute ] },
];
export const asyncRoutes: AsyncRoutes = {
'Detail': require('es6-promise-loader!./+detail'),
'Foo': require('es6-promise-loader!./+foo')
};
export const prefetchRouteCallbacks: Array<IdleCallbacks> = [
asyncRoutes['Detail'],
asyncRoutes['Foo']
];
我甚至无法更改路线名称。
export const routes: RouterConfig = [
{ path: 'detail', component: 'Foo', canActivate: [ WebpackAsyncRoute ] },
];
export const asyncRoutes: AsyncRoutes = {
'Foo': require('es6-promise-loader!./+detail'),
};
export const prefetchRouteCallbacks: Array<IdleCallbacks> = [
asyncRoutes['Foo'],
];
发生了什么事?
答案 0 :(得分:0)
实施以下内容: [ 新的AsyncRoute({ 路径:&#39; /&#39; ,name:RouterService.CONTROL_CENTER_ROUTE ,loader :()=&gt;新承诺((resolve:any)=&gt; { (要求)。确保([&#39;控制center.component&#39;] ,(要求:任何)=&gt; 决心(要求(&#39;控制center.component&#39;。)ControlCenterComponent)); }) ,useAsDefault:true }) ,新的AsyncRoute({ 路径:&#39; / login&#39; ,name:RouterService.LOGIN_ROUTE ,loader :()=&gt;新承诺((resolve:any)=&gt; { (要求)。确保([&#39; login.component&#39;] ,(要求:任何)=&gt; 决心(要求(&#39; login.component&#39;)LoginComponent)); }) }) ];
有关详细信息,请参阅此博客 enter link description here