【问题标题】:en.json 'Not Found' when serving SB Admin Bootstrap 4 template提供 SB Admin Bootstrap 4 模板时的 en.json 'Not Found'
【发布时间】:2018-02-01 19:25:12
【问题描述】:

我正在使用这个模板:

https://github.com/start-angular/SB-Admin-BS4-Angular-4

ng serve 总是在控制台中抛出错误:

获取 http://localhost:4200/start-angular/SB-Admin-BS4-Angular-4/master/dist/assets/i18n/en.json 404(未找到)- zone.js:2263

错误响应{_body:“↵↵↵↵↵↵”,状态:404, 好的:false,statusText:“未找到”,标题:标题,...} core.es5.js:1020

您将如何解决该错误?

【问题讨论】:

  • 如果是404,你能在浏览器中输入localhost:4200/assets/i18n/en.json吗?
  • 显示这个:{“dashboard”:“Dashboard”,“charts”:“Charts”,“tables”:“Tables”,“forms”:“Forms”,“boostrapElement”:“Boostrap元素”,“boostrapGrid”:“Boostrap Grid”,“组件”:“组件”,“菜单”:“菜单”,“子菜单”:“子菜单”,“空白页”:“空白页”,“更多主题”:“更多主题”、“downloadNow”:“立即下载”、“语言”:“语言”}
  • 告诉我你如何在代码中引用该文件。
  • 我不知道参考来自哪里...因为是模板。第一次打开,出现错误

标签: angular angular-cli zone.js


【解决方案1】:

您通往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');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-12
    • 2017-11-06
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 2022-08-19
    • 2017-10-23
    相关资源
    最近更新 更多