我正在使用此模板:
https://github.com/start-angular/SB-Admin-BS4-Angular-4
在ng serve
上,它总是在控制台中抛出错误:
GET http://localhost:4200/start-angular/SB-Admin-BS4-Angular-4/master/dist/assets/i18n/en.json 404(未找到) - zone.js:2263
ERROR Response {_body:“↵↵↵↵↵↵”,状态:404, ok:false,statusText:“Not Found”,header:Headers,...} core.es5.js:1020
您如何解决该错误?
答案 0 :(得分:2)
en.json
的路径错误
它应该类似于http://localhost:4200/assets/i18n/en.json
<强>更新强>
我只是寻找来源。您需要使用app.module.ts
文件行14和13 https://github.com/start-angular/SB-Admin-BS4-Angular-4/blob/master/src/app/app.module.ts#L14
export function HttpLoaderFactory(http: Http) {
// for development
// return new TranslateHttpLoader(http, '/start-angular/SB-Admin-BS4-Angular-4/master/dist/assets/i18n/', '.json');
return new TranslateHttpLoader(http, '/assets/i18n/', '.json');
}