简体   繁体   English

TypeScript中jQuery对象的类型是什么?

[英]What is the type of a jQuery object in TypeScript?

This is going to be a really short one. 这将是一个非常短的过程。

I'm just wondering what type I should use for jQuery elements? 我只是想知道应该为jQuery元素使用哪种类型?

Without jQuery I go on like this: 没有jQuery,我会像这样继续:

export class Modal {

    constructor(protected element:HTMLElement) {

    }
}

But, lets say element will be a jQuery selector like $('.myDiv') for example. 但是,可以说element将是一个像$('.myDiv')这样的jQuery选择器。 What type should element then have? element应该具有什么类型?

After installing the types needed ( npm install --save-dev @types/jquery ), you can type it as just JQuery : 安装所需的类型( npm install --save-dev @types/jquery )后,可以将其键入为JQuery

constructor(protected element: JQuery) {

}

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

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