初始化jQuery日期选择器 [英] Initialise JQuery Date Picker
问题描述
我有以下代码
$.datepicker.setDefaults({ dateFormat: 'dd/mm/yy' });
var searchStartDate = moment((<any>$('#searchStart')).datepicker('getDate'));
var searchEndDate = moment((<any>$('#searchEnd')).datepicker('getDate'));
第一行上的日期选择器出现错误:
I am getting an error on datepicker on the first line:
"JQueryStatic"类型的值不存在属性"datepicker"
The property "datepicker" does not exist on value of type "JQueryStatic"
有人可以指出正确的方向来解决它吗?
Can someone point me in the right direction to fix it please?
推荐答案
看起来您有jQuery声明文件,但没有 jQuery UI 声明文件.在此处可用: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jqueryui
It looks like you have the jQuery declaration file but not the jQuery UI declaration file. It's available here: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jqueryui
编辑:现代TypeScript开发是通过npm安装软件包,而不是手动下载文件.用npm install --save @types/jqueryui
安装声明文件.
Edit: Modern TypeScript development is installing packages through npm rather than downloading files manually. Install the declaration file with npm install --save @types/jqueryui
.
这篇关于初始化jQuery日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!