gpt4 book ai didi

jquery - TypeScript 与 Jquery

转载 作者:行者123 更新时间:2023-12-01 07:47:12 25 4
gpt4 key购买 nike

我收到此错误“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,如果问题出在类型上,那么您会看到编译器错误。

查看现有问题: Uncaught ReferenceError: $ is not defined?

关于jquery - TypeScript 与 Jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35226871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com