我收到此错误“Uncaught ReferenceError:$未定义”,请在下面找到我的代码。
///<reference path="jquery.d.ts" />
class Test {
name: string;
constructor() {
this.name = "gowtham";
}
dispname() {
alert("Name :" + this.name);
}
}
$(document).ready(function () {
debugger;
var test = new Test();
$('#test').on('click', function() {
debugger;
test.dispname();
});
});
我的 .ts 文件中也有引用 reference path="jquery.d.ts" 。我在这里错过了什么吗?
最佳答案
您收到运行时错误是因为您没有正确加载 JQuery,如果问题出在类型上,那么您会看到编译器错误。
关于jquery - TypeScript 与 Jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35226871/