TypeScript with Jquery [英] TypeScript with Jquery

查看:115
本文介绍了TypeScript with Jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误未捕获的ReferenceError:$未定义请在下面找到我的代码。

I am getting this error "Uncaught ReferenceError: $ is not defined" please find my code below.

///<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();
    });

});

我也有参与参考路径=jquery.d.ts在我的.ts文件中。我在这里遗漏了什么。?

i am having the referance too reference path="jquery.d.ts" in my .ts file. Am i missing anything here .?

推荐答案

您收到运行时错误,因为您没有正确加载JQuery,如果问题与打字有关,那么你会看到编译器错误。

You're getting a runtime error because you haven't loaded JQuery properly, if the issue was with the typings then you would've seen a compiler error.

查看现有问题:
未捕获的ReferenceError:$未定义?

这篇关于TypeScript with Jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆