这是本文档旧的修订版!


Angular 进阶

国际化 i18n

HTTP

搜索结果

mail.simperator.com

ff

问题集

问题一:404报错

Angular 刷新页面的时候出现 404 错误。有两个解决方案, 方法二测试有效

方案一

import { LocationStrategy, HashLocationStrategy } from '@angular/common';
@NgModule({
  providers: [
    { provide: LocationStrategy, useClass: HashLocationStrategy }
  ]
})

方法二

imports: [RouterModule.forRoot(routes), RouterModule.forRoot(routes, {useHash: true})],

问题二:运行时出错 以下代码在 ng serve 时没有问题,但 ng build 并推送到服务器之后就出现运行时错误。

download

if(options?.headers !== null){
  (options?.headers as any).Authorization = `Bearer ${BaseSetting.AccessToken}`
}

需要更改为

download

var hd:any = options?.headers
hd.Authorization = `Bearer ${BaseSetting.AccessToken}`
it/framework/angurlar.1684662227.txt.gz · 最后更改: 2023-05-21 09:43 由 goldentianya
回到顶部
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0