element.ui时间验证结束时间大于开始时间

 let validateStartTime = (rule, value, callback) => {
        if(!value){
          callback(new Error("请选择开始时间"));
        }else{
          if(this.form.endTime){
            this.$refs.ruleForm.validateField('endTime');
          }
          callback();
        }
      };
      let validateEndTime = (rule, value, callback) => {
        if(!value){
          callback(new Error("请选择结束时间"));
        }else{
          if(!this.form.startTime){
            callback(new Error("请选择开始时间!"))
          }else if(Date.parse(this.form.startTime) >= Date.parse(value)){
            callback(new Error("结束时间必须大于开始时间!"))
          }else{
            callback();
          }
        }
      };
 rules: {
          start_time: [{
            required: true,
            validator: validateStartTime,
            trigger: "blur"
          }],
          end_time: [{
            required: true,
            validator: validateEndTime,
            trigger: "blur"
          }],
        },

你可能感兴趣的:(VUE,VUE,element.ui,时间验证)