Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery $(this.closest(";form";)上的Typescript错误。valid()_Jquery_Jquery Validate_Typescript - Fatal编程技术网

Jquery $(this.closest(";form";)上的Typescript错误。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,

我有jquery和jquery.validation的输入,但仍然在$(this.closest(“form”).valid()上出错 “JQuery”类型的值上不存在属性“valid” 有没有我丢失的打字机? 谢谢

请自行修复:

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;
}