jspm/jQuery/TypeScript - 模块“jquery”没有默认导出
问题描述:
我试图引导一个Web应用程序使用TypeScript和jspm & system.js模块加载。我不是很远。jspm/jQuery/TypeScript - 模块“jquery”没有默认导出
jspm install jquery
而且基础:
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('main');
</script>
main.ts:安装JSPM,并用它来安装的jQuery后
import $ from "jquery";
export class Application {
constructor() {
console.log($);
}
}
打字稿不能编译,因为“模块“ jquery'没有默认导出
生成的config.js有正确的映射:“jquery”:“npm:jquery @ 2.2.0"
答
当模块没有默认的导出,可以导入完整的模块对象:import * as $ from "jquery";
或导入命名出口: import { ajax, css } from "jquery";
+1
命名的导出不起作用。模块jquery没有导出成员'css'。 – mradzinski
+0
不要忘记运行:npm安装jquery。 – user321
你有没有试过'进口*为$从“jquery”;'? –
谢谢你的作品!如果您将此作为答案提交,我可以接受。 – user888734
这对我有用! – Dan