如何使Angular2路由器更快

如何使Angular2路由器更快,angular,angular2-routing,Angular,Angular2 Routing,在Angular 1中,应用程序在初始加载时需要1-3秒才能获取所有资源并初始化。在此之后,导航到不同的路由只需将#tab1附加到url,并立即切换到该路由 在Angular2中仍然可以这样做吗 由于angular.io上的以下示例,每个路由都会重新加载整个应用程序,这需要1-3秒的时间,同时使用加载程序查看空白屏幕。它不附加#路径。我应该使用不同的路由器恢复到那个速度吗 index.html <html> <head> <base href="/">

在Angular 1中,应用程序在初始加载时需要1-3秒才能获取所有资源并初始化。在此之后,导航到不同的路由只需将#tab1附加到url,并立即切换到该路由

在Angular2中仍然可以这样做吗

由于angular.io上的以下示例,每个路由都会重新加载整个应用程序,这需要1-3秒的时间,同时使用加载程序查看空白屏幕。它不附加#路径。我应该使用不同的路由器恢复到那个速度吗

index.html

<html>
<head>
  <base href="/">

存在延迟加载路由。您可以在此处了解这一点,如果发生这种情况,您的设置可能存在严重错误。您能否尝试切换到HashLocationStrategy?您是否在
元素(或
APP\u BASE\u HREF
中提供了
)中有
?你的html头上有
吗?@GünterZöchbauer很高兴听到这个消息!位于index.htmlPlease的头部,请尝试一下,谢谢,速度肯定更快,但所有的路由都搞糟了。如中所示,地址栏中的路径落后于一次单击,选项卡选择不正确。
const appRoutes: Routes = [
  { path: 'classes', component: ClassesComponent },
  { path: 'classes/:id', component: ClassDetailComponent },
  { path: 'products', component: ProductsComponent },
  { path: 'products/:id', component: ProductDetailComponent },
  { path: '', redirectTo: 'products', pathMatch: 'full' },
  { path: 'cache/clear', component: CacheComponent },
  { path: '**', component: PageNotFoundComponent }
];

export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);