【发布时间】:2017-08-08 03:56:55
【问题描述】:
我正在使用 angular4 开发应用程序。 现在我正在开发l
export function createTranslateLoader(http: Http) {
let fullLocationPath = location.host + location.pathname;
return new TranslateHttpLoader(http, fullLocationPath + 'assets/languages/', '.json');
}
但我得到了下一个错误:
XMLHttpRequest 无法加载 localhost:4200/assets/languages/en.json。 跨域请求仅支持协议方案:http、 数据,铬,铬扩展,https。
我该如何解决它?
【问题讨论】:
-
我猜你是在文件系统中本地“开发”。您在浏览器中的应用程序的网址是什么?
-
URL - localhost:4200
-
在运行应用程序或打开构建文件时?
标签: javascript angular http typescript