vue-element-admin的小总结

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);
              }
            }
          });
        }
      });

 4、vue-element-admin - 配置接口请求,跨域,版本4

https://www.cnblogs.com/gggggggxin/p/12988853.html

原文地址:https://www.cnblogs.com/fkcqwq/p/13275615.html