在使用element-UI 的表單時,發生一個驗證錯誤,例如已輸入值但求驗證糾錯:post
代碼以下所示:fetch
<el-form :model="correction" :inline="true" :rules="rules" ref="correctionForm" class="demo-ruleForm" >
<el-form-item label="聯繫人郵箱" prop="correctorEmail" label-suffix="sfdfsd">
<el-input v-model="correction.correctorEmail" ></el-input>
</el-form-item>
</el-form>
rules: { correctorEmail: [ { required: true, message: '請輸入聯繫人郵箱地址', trigger: 'blur' }, ], },
綁定都是沒有錯誤的,而後咱們利用自定義校驗規則驗證ui
this.$refs[formName].validate((valid) => { if (valid) { Http.fetch({ method: "post", url: `${master}/exter/catalog/correction`, data:vm.correction }).then((res)=>{ if (res.status == 200) { if (res.data.result) { vm.dialogFormVisible = false; //關閉對話框
vm.$message({ showClose: true, message: '糾錯成功!', type: 'success' }); vm.loadData(); vm.disable = true; } else { vm.$message({ type: "error", title: '糾錯失敗', message: res.message, }); } } vm.disable = false; }) } else { console.log('error submit!!'); return false; } });