1、vue-element-admin的input的驗證殘留清除
this.$refs["from"].resetFields(); //移除校驗結果並重置字段值 this.$refs["from"].clearValidate(); //移除校驗結果
2、在elementUI中有時想觸發el-form中的某一個校驗,該怎么做?
<el-form :model="form" ref="form" class="mt20" label-width="140px"> <el-form-item label="標題:" prop="title" :rules="{required:true,message:'請輸入標題',trigger:'change'}"> <el-input v-model="form.title" size="small" placeholder="請輸入標題"></el-input> </el-form-item> </el-form> //單獨觸發 this.$refs.form.validateField('title')
3、在elementUI中當觸發一個校驗成功后再進行校驗下一個,需要在調用.validateField()方法時,傳一個回調函數;
this.$refs.resetForm.validateField(["phone"], errMsg => { if (errMsg) { return false; } else { this.$refs.resetForm.validateField(["passwordAgain"], errMsg => { if (errMsg) { return false; } else { const TIME_COUNT = 60; //更改倒計時時間 if (!this.timer) { this.count = TIME_COUNT; this.show = false; this.timer = setInterval(() => { if (this.count > 0 && this.count <= TIME_COUNT) { this.count--; } else { this.show = true; clearInterval(this.timer); // 清除定時器 this.timer = null; } }, 1000); } } }); } });