Angular 2-使用HashLocationStrategy时基本href是否冗余

Angular 2-使用HashLocationStrategy时基本href是否冗余,angular,angular2-routing,Angular,Angular2 Routing,从ng1移动到ng2,我想继续使用锚散列'#'进行路由 export const ROUTES: Routes = [{ path: '', redirectTo: 'login', pathMatch: 'full' }, { path: 'app', component: AppComponent }, { path: 'login', component: LoginComponent }, { path: 'error', component

从ng1移动到ng2,我想继续使用
锚散列'#'
进行路由

 export const ROUTES: Routes = [{
   path: '', redirectTo: 'login', pathMatch: 'full'
  }, {
    path: 'app',  component: AppComponent
  }, {
    path: 'login', component: LoginComponent
  }, {
    path: 'error', component: ErrorComponent
  }
];
另外,ng2使用默认的PathLocationStrategy,其中我们定义了一个
,这是angular 2路由器用于客户端路由的基本路径,已记录在案

 export const ROUTES: Routes = [{
   path: '', redirectTo: 'login', pathMatch: 'full'
  }, {
    path: 'app',  component: AppComponent
  }, {
    path: 'login', component: LoginComponent
  }, {
    path: 'error', component: ErrorComponent
  }
];
由于我使用的是HashLocationStrategy,如果我从index.html中删除
,是否会出现任何问题?我已经创建了一个带有以下路线的小应用程序,它似乎运行良好

 export const ROUTES: Routes = [{
   path: '', redirectTo: 'login', pathMatch: 'full'
  }, {
    path: 'app',  component: AppComponent
  }, {
    path: 'login', component: LoginComponent
  }, {
    path: 'error', component: ErrorComponent
  }
];

谢谢,

如果您将useHash:true与Approute一起使用,则无需提供base href
 export const ROUTES: Routes = [{
   path: '', redirectTo: 'login', pathMatch: 'full'
  }, {
    path: 'app',  component: AppComponent
  }, {
    path: 'login', component: LoginComponent
  }, {
    path: 'error', component: ErrorComponent
  }
];

因为它是多余的,因为两者都有助于刷新页面,但遵循不同的概念。

无论如何,它应该是
。好的,您不需要它来编辑
HashLocationStrategy
@GünterZöchbauer,谢谢您的确认。本QA为您提供了详细信息
 export const ROUTES: Routes = [{
   path: '', redirectTo: 'login', pathMatch: 'full'
  }, {
    path: 'app',  component: AppComponent
  }, {
    path: 'login', component: LoginComponent
  }, {
    path: 'error', component: ErrorComponent
  }
];