<div class="form">
<el-form
:model="directorForm"
:rules="directoRules"
ref="formRef"
label-width="130px"
class="demo-ruleForm"
>
<el-form-item label="负责人姓名:" prop="name">
<el-input
v-model="directorForm.name"
style="width:400px"
placeholder="请填写负责人姓名"
></el-input>
</el-form-item>
<el-form-item label="负责人联系电话:" prop="phone">
<el-input
v-model="directorForm.phone"
style="width:400px"
placeholder="请填写负责人联系电话"
></el-input>
</el-form-item>
<!-- <el-form-item style="margin-top:40px">
<el-button type="primary" @click="submitForm('ruleForm')"
>确认提交</el-button
>
</el-form-item> -->
</el-form>
<el-button type="primary" @click="submitForm">确认提交</el-button>
</div>
submitForm() {
// formRef
//会报错改成this.$refs.formRef.validate((valid) => {}
this.$refs[formRef].validate((valid) => {
if (valid) {
alert('submit!')
} else {
console.log('error submit!!')
return false
}
})
}
会报错改成this.$refs.formRef.validate((valid) => {}