element 时间过滤

element 时间过滤

需求:学生选择假期,再选取时间,时间必须在假期中

element 时间过滤



  • 核心vue代码

    <el-form-item label="申请假期">
      <el-autocomplete
        v-model="stayAtSchoolForm.stay_at_school_id"
        :fetch-suggestions="stay_at_school_idQuerySearchAsync"
        placeholder="请输入内容"
        @select="stay_at_school_idHandleSelect"
      ></el-autocomplete>
    </el-form-item>



    <el-form-item label="开始时间 ">
      <el-date-picker
        v-model="stayAtSchoolForm.start_date"
        type="datetime"
        :disabled="disableTime"
        :picker-options="pickerOptionsStartTime"
        placeholder="选择日期时间">
      </el-date-picker>
    </el-form-item>

    <el-form-item label="结束时间 ">
      <el-date-picker
        v-model="stayAtSchoolForm.end_date"
        type="datetime"
        :disabled="disableTime"
        :picker-options="pickerOptionsEndTime"
        placeholder="选择日期时间">
      </el-date-picker>
    </el-form-item>


	data() {
      return {
        ***
     //用()=>{}  就能拿到this,就能拿到数据。用  函数名(){}就拿不到this
        pickerOptionsStartTime:{
          disabledDate:(time)=>{
            return  time.getTime() < new Date(Date.parse(this.vacation_start_time));
          }
        },

       //用()=>{}  就能拿到this,就能拿到数据。用  函数名(){}就拿不到this  
        pickerOptionsEndTime:{
          disabledDate:(time)=>{
            return new Date(Date.parse(this.vacation_end_time)) < time.getTime() ;
          }
        },

      }
    },
 
上一篇:JSON.stringify和JSON.parse 的一些不为人知的地方


下一篇:爬取渐变风格插画