我对Angular7应用程序有一个奇怪的行为。每次我点击刷新,它就会失去路线的轨迹,给我一个404。我在很多地方都读过关于配置web.config文件为了解决这个问题,但是即使配置了它,我也无法摆脱这种行为。
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
模块配置
@NgModule({
imports: [
AppRoutingModule,
SharedModule,
HttpClientModule,
AuthModule,
StoreModule.forRoot(reducers, { metaReducers }),
EffectsModule.forRoot(effects),
StoreRouterConnectingModule,
environment.development ? StoreDevtoolsModule.instrument() : []
],
declarations: [AppComponent],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
{ provide: RouterStateSerializer, useClass: CustomSerializer }],
bootstrap: [AppComponent]
})
export class AppModule {}
<base href="/" />
在我的头上索引.html文件