app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers:
[BureauApiService,BureauStateWorkflowComponent,CommondataApiService]
})
export class AppComponent implements OnInit {
constructor(
private router: Router,
private bureau:BureauStateWorkflowComponent,
private _location: Location,
) { }
ngOnInit(){
//this.bureau.getPosts();
this.router.navigate(['/']);
localStorage.clear();
}
}
在Local主机中,此路由器在浏览器刷新时正确工作。但是在IIS中部署后,它行不通。返回此类型错误页面。HTTP错误404.0-找不到您要查找的资源已被删除,更改了名称或暂时不可用。
最后,我找到了答案。我在app.module.ts类中使用了位置策略和hashlocationstrategy to app.module.ts class和app.component.ts类中的提供者
在app.module.ts
中import { HashLocationStrategy,LocationStrategy } from '@angular/common';
@NgModule({
providers: [Configurations, BureauApiService, CreditorApiService,{provide:
LocationStrategy, useClass: HashLocationStrategy},FlashMessagesModule],
})
export class AppModule { }
在app.component.ts
中ngOnInit(){
//this.bureau.getPosts();
this.router.navigate(['/#']);
localStorage.clear();
}
它可以正常工作