zoukankan      html  css  js  c++  java
  • element -validateField校验提示

    <el-form :model="numberValidateForm" ref="numberValidateForm" :rules="rules"  label-width="100px" class="demo-ruleForm">
      <el-form-item
          label="年龄"
          prop="age">
        <el-input type="number" v-model="numberValidateForm.age"></el-input>
      </el-form-item>

    根据接口异常提示。用过  validateField



        data() {
        var ageValidate = (rule, value, callback) => {
          if (this.smsMsg) {
            callback(new Error(this.smsMsg));
          }else{
            callback();
          }
        };
    ....

     rules:{
            age:[
              {required: true, message: "年龄不能为空", trigger: 'blur'},
              {validator: ageValidate}
            ]
          }

    提交请求信息,返回错误

    submitForm(formName) {
          var _this = this;
          _this.$refs[formName].validate((valid) => {
            if (valid) {
              setTimeout(function(){ // 模拟请求
                _this.smsMsg = '年龄有误';
                if(_this.smsMsg){ // 服务有返回错误
                  _this.$refs[formName].validateField("age");
                  _this.smsMsg = '';
    }else{ alert("submit") } },1000); } else { console.log('error submit!!'); return false; } }); },
  • 相关阅读:
    MongoDB 查询$关键字 $in $or $all
    MongoDB limit 选取 skip跳过 sort排序 方法
    POJ 1700
    POJ 1666
    POJ 1701
    POJ 1674
    POJ 1664
    POJ 1665
    POJ 1658
    POJ 1656
  • 原文地址:https://www.cnblogs.com/congxueda/p/8884773.html
Copyright © 2011-2022 走看看