TypeScript中jQuery对象的类型是什么? [英] What is the type of a jQuery object in TypeScript?
本文介绍了TypeScript中jQuery对象的类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这将是一个很短的
我只是想知道应该为jQuery元素使用哪种类型?
I'm just wondering what type I should use for jQuery elements?
在没有jQuery的情况下,我继续这样:
Without jQuery I go on like this:
export class Modal {
constructor(protected element:HTMLElement) {
}
}
但是,可以说element
将是像$('.myDiv')
这样的jQuery选择器. element
应该具有什么类型?
But, lets say element
will be a jQuery selector like $('.myDiv')
for example. What type should element
then have?
推荐答案
安装所需的类型(npm install --save-dev @types/jquery
)后,可以将其键入为JQuery
:
After installing the types needed (npm install --save-dev @types/jquery
), you can type it as just JQuery
:
constructor(protected element: JQuery) {
}
这篇关于TypeScript中jQuery对象的类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文