报错信息如下
Property 'validate' dose not exist on type 'Element | Element[] | vue | vue[]'. property 'validate' dose not exist on type 'Element'.
代码书写如下
submitData() {
this.$refs['form'].validate((valid:any) => {
if(valid) {
console.log('验证通过')
} else{
console.log('验证失败')
}
})
}
正确的代码书写
let $form:any = this.$refs.form
$form.validate((valid:any) => {
if (valid) {
console.log('验证通过')
} else {
console.log('验证失败')
}
})