【问题标题】:System.import loading module but not executing any code within itSystem.import 加载模块但不执行其中的任何代码
【发布时间】:2015-12-02 05:01:10
【问题描述】:

我有一个名为 index.js 的文件,如下所示:

import Backbone from 'backbone'
import _ from 'underscore'
import $ from 'jquery'

console.log("blah")
export default {...}

在我的index.html 我有:

<script>
  System.import('index');
</script>

但令我困惑的是,我可以看到文件正在加载(在开发工具网络面板中),但 console.log 从未运行。如果是这种情况,我该如何引导我的应用程序?

一些在线教程建议在 System.import 文件中引导它,但如果不执行代码怎么办?

【问题讨论】:

    标签: systemjs es6-module-loader


    【解决方案1】:

    我最终使用三个匿名函数将.then() 添加到System.import,所有这些函数都只有一个debugger,并发现import $ from 'jquery' 超时,因为我没有安装库。我删除了导入声明,应用程序仍在尝试加载 jquery,所以我安装了它并解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 2021-10-04
      • 1970-01-01
      • 2011-11-19
      相关资源
      最近更新 更多