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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM