美文网首页
el-form表单el-form-item验证规则里prop一次

el-form表单el-form-item验证规则里prop一次

作者: CoolBoy_52e5 | 来源:发表于2022-06-11 16:52 被阅读0次
    <el-form-item label="随机区间" prop="randowMin" v-if="infoData.type !== 4 && infoData.isRandow === 1">
      <div class="input_item">
        <div class="input_item_value input_item_value2">
          <el-input v-model="infoData.randowMin" placeholder="请输入内容"></el-input>
        </div>
        <span>-</span>
        <div class="input_item_value input_item_value2">
          <el-input v-model="infoData.randowMax" placeholder="请输入内容"></el-input>
        </div>
      </div>
    </el-form-item>
    
    data() {
      const valTowValue = (rule, value, callback) => {
        if (value == "" || value == undefined || value == null) {
          callback(new Error("请输入随机区间"));
        } else {
          if (!this.infoData.randowMax) {
            callback(new Error("请输入最大值"));
          } else if (!this.infoData.randowMin) {
            callback(new Error("请输入最小值"));
          } else if (Number(this.infoData.randowMin) >= Number(this.infoData.randowMax)) {
            callback(new Error("请输入正确的范围值"));
          } else {
            callback();
          }
        }
      };
    }
    
    rules: {
      randowMin: [{ validator: valTowValue, trigger: "blur" }],
    },
    

    相关文章

      网友评论

          本文标题:el-form表单el-form-item验证规则里prop一次

          本文链接:https://www.haomeiwen.com/subject/llcxmrtx.html