【发布时间】:2018-01-12 15:02:15
【问题描述】:
我在 Typescript 中添加了 JQuery,但出现了这个错误:
未捕获的引用错误:未定义导出
代码 TS:
import * as $ from 'jquery'
$('.test').click(function(eventObject){
alert('med');
})
代码js:
"use strict";
exports.__esModule = true;
var $ = require("jquery");
$('.test').click(function (eventObject) {
alert('med');
});
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "es6",
"pretty": true,
"experimentalDecorators":true
},
"files": [
"demo.ts",
"typings/index.d.ts"
],
"excluse": ["node_modules"]
}
如何解决这个错误?
【问题讨论】:
-
你能发布你的 tsconfig 文件吗?
-
你从哪里得到这个错误?
-
您是否安装了
@types/jquery和jquerynpm 包? -
@rgvassar ,我在添加代码 tsconfig 时更新了我的问题
-
@unional ,我在控制台中有这个错误(在代码 js 中)
标签: jquery typescript