elementUI的验证为什么@click="submitForm(formRef)"可以,而直接使用ref()就不行?-灵析社区

木子弓长

Submit Reset import { reactive, ref } from 'vue' import type { FormInstance } from 'element-plus' const formRef = ref() const numberValidateForm = reactive({ age: '', }) const submitForm = () => { if (!formRef) return formRef.validate((valid) => { if (valid) { console.log('submit!') } else { console.log('error submit!') return false } }) } const resetForm = (formEl: FormInstance | undefined) => { if (!formEl) return formEl.resetFields() }

阅读量:231

点赞量:0

问AI
销售经理537
得是 "formRef.value.validate()" 吧…… 在 "script" 中使用 "ref" 的加上 ".value"