初始化jQuery日期选择器 [英] Initialise JQuery Date Picker

查看:94
本文介绍了初始化jQuery日期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码

$.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屋!

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