第一种解决方案,在app.route.ts中加入{
useHash:true}
@
NgModule({
imports: [
RouterModule.
forRoot(
APPROUTES,{
useHash:
true})],
exports: [
RouterModule]
})
第二种解决方案,app.module.ts修改providers,加入如下代码
import { CommonModule, HashLocationStrategy,LocationStrategy } from '@angular/common';
providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}],