【问题标题】:VS2015 + TypeScript + Cordova + Angular2 + SystemJSVS2015 + TypeScript + Cordova + Angular2 + SystemJS
【发布时间】:2023-03-10 13:20:01
【问题描述】:

systemJS 加载外部模块时遇到问题。我为 VS2015 创建了一个小示例项目。你可以在这里下载代码https://github.com/dbiele/TypeScript-Cordova-SystemJS

当我在 Ripple 或 BrowserSync 中构建项目并查看时,我收到以下错误:xhr_proxy。看起来System 正在registry.jspm.io 上寻找外部文件animate.js,而它应该在localhost 上找到它。

有什么想法吗? GitHub 中的代码非常基础。注意:我认为这不是 Cordova 问题,因为我是在浏览器中运行并产生波纹。

【问题讨论】:

    标签: typescript visual-studio-2015 visual-studio-cordova systemjs


    【解决方案1】:

    发现问题。 TypeScript 在导入/导出外部模块时不使用 .js 扩展。例如:

    打字稿

    import * as Animate from './animate';
    

    ES6

    import * as Animate from './animate.js';
    

    解决方法是在system.config中添加defaultJSExtensions: true

    例子:

    System.config({
        baseURL: './scripts/',
        paths: { 'App': 'app.js' },
        defaultJSExtensions: true
    });
    

    我这里更新了VS2015项目代码,效果很好。

    https://github.com/dbiele/TypeScript-Cordova-SystemJS

    @DatenMetzgerX 也有同样的问题。发布信息: https://github.com/systemjs/systemjs/issues/490

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      相关资源
      最近更新 更多