Jquery $(this.closest(";form";)上的Typescript错误。valid()
我有jquery和jquery.validation的输入,但仍然在$(this.closest(“form”).valid()上出错 “JQuery”类型的值上不存在属性“valid” 有没有我丢失的打字机? 谢谢请自行修复:Jquery $(this.closest(";form";)上的Typescript错误。valid(),jquery,jquery-validate,typescript,Jquery,Jquery Validate,Typescript,我有jquery和jquery.validation的输入,但仍然在$(this.closest(“form”).valid()上出错 “JQuery”类型的值上不存在属性“valid” 有没有我丢失的打字机? 谢谢请自行修复: interface JQuery{ valid:any; } 更好的解决方案: 使用此定义: 定义是什么 此定义中的重要部分(不要复制粘贴…只指出社区的努力) 为了将来 您需要为您使用的每个库使用一个定义 我查看了定义文件,可以看到Valid:boolean,
interface JQuery{
valid:any;
}
更好的解决方案:
使用此定义:
定义是什么
此定义中的重要部分(不要复制粘贴…只指出社区的努力)
为了将来
您需要为您使用的每个库使用一个定义 我查看了定义文件,可以看到Valid:boolean,但无论编译或重述visual studio多少次,它都不起作用。 今天早上重新启动visual studio后,错误消失了
谢谢您是否包含了验证插件,在包含jQuery库之后添加
。另外,请在标记时更加小心。jQuery验证引擎不是jQuery验证插件。编辑。谢谢。正如Arun所问的,您是否记得正确地包含jQuery验证插件?否则,.valid()
方法不是标准jQuery库的一部分。谢谢,验证工作正常,只是在typescript中我得到了错误。
interface JQuery
{
/**
* Remove the specified attributes from the first matched element and return them.
*
* @param attributes A space-seperated list of attribute names to remove.
*/
removeAttrs(attributes: string): any;
/**
* Returns the validations rules for the first selected element
*/
rules(): any;
/**
* Removes the specified rules and returns all rules for the first matched element.
*
* @param command "remove"
* @param rules Removes and returns all rules. Manipulates only rules specified via rules-option or via rules("add").
*/
rules(command: string): any;
/**
* Removes the specified rules and returns all rules for the first matched element.
*
* @param command "remove"
* @param rules The space-separated names of rules to remove and return. Manipulates only rules specified via rules-option or via rules("add").
*/
rules(command: string, rules: string): any;
/**
* Adds the specified rules and returns all rules for the first matched element. Requires that the parent form is validated, that is, $("form").validate() is called first
*
* @param command "add"
* @param rules The rules to add. Accepts the same format as the rules-option of the validate-method.
*/
rules(command: string, rules: Object): any;
/**
* Checks whether the selected form is valid or whether all selected elements are valid.
*/
valid(): boolean;
/**
* Validates the selected form.
*
* @param options options for validation
*/
validate(options?: ValidationOptions): Validator;
}