我正在尝试使用 TypeScript 和 jspm & system.js 引导一个网络应用程序来加载模块。我不会走得太远。安装 jspm 并使用它安装 jQuery 后:
jspm install jquery
基础知识:
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('main');
</script>
main.ts:
import $ from "jquery";
export class Application {
constructor() {
console.log($);
}
}
TypeScript 无法编译,因为“模块‘jquery’没有默认导出。
生成的 config.js 具有正确的映射:"jquery": "npm:jquery@2.2.0"
最佳答案
当模块没有默认导出时,您可以将整个模块作为对象导入:import * as $ from "jquery";
或导入命名导出:
从 "jquery"导入 { ajax, css };
关于javascript - jspm/jQuery/TypeScript - 模块 "jquery"没有默认导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35223977/