Javascript 在角度应用程序中使用TranslateHttpLoader时出错

Javascript 在角度应用程序中使用TranslateHttpLoader时出错,javascript,angular,http,typescript,Javascript,Angular,Http,Typescript,我正在用angular4开发应用程序。 现在我正在开发我的 export function createTranslateLoader(http: Http) { let fullLocationPath = location.host + location.pathname; return new TranslateHttpLoader(http, fullLocationPath + 'assets/languages/', '.json'); } 但我得到了下一个错误:

我正在用angular4开发应用程序。 现在我正在开发我的

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, 数据,chrome,chrome扩展,https


如何修复它?

在代码中看不到使用
fullLocationPath
的位置,但需要在其前面添加
位置。协议
,或者更好地使用
位置。原点

let fullLocationPath = location.origin + location.pathname;

我猜您是在本地文件系统中“开发”的。您在浏览器中的应用程序的url是什么?运行应用程序或打开生成文件时的url-localhost:4200?