解决Property ‘validate‘ does not exist on type Vue 的问题方法总结

 同时适用于各种 "Property xxx does not exist on type 'Vue'"的问题,在此仅以表单验证的场景为例

 解决方法1:先定义,再引用

let form: any = this.$refs.form

form.validate((valid: Boolean) => {})

解决方法2:(xxx as any).xxx语法

this.type = 'test'
(this.$refs['form'] as any).validate((valid : boolean)=> {
     ... ...
})

至此,问题解决。

猜你喜欢

转载自blog.csdn.net/a1059526327/article/details/109463079