繁体   English   中英

jspm / jQuery / TypeScript - 模块“jquery”没有默认导出

[英]jspm / jQuery / TypeScript - module “jquery” has no default export

我正在尝试使用TypeScript和jspm&system.js来引导Web应用程序以进行模块加载。 我没有走得太远。 安装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将无法编译,因为“Module'jquery'没有默认导出。

生成的config.js具有正确的映射:“jquery”:“npm:jquery@2.2.0”

当模块没有默认导出时,您可以将完整模块作为对象import * as $ from "jquery";import * as $ from "jquery";

或者import { ajax, css } from "jquery";导入命名导出: import { ajax, css } from "jquery";

如果您使用的是visual studio ,请更新typescript插件。

要获得2017年Visual Studio的最新版本, 请去那里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM