其他分享
首页 > 其他分享> > ElementUl日期组件 选择范围特定起始时间到今天

ElementUl日期组件 选择范围特定起始时间到今天

作者:互联网

      <el-date-picker
        :clearable="en_clearable"
        v-model="data_value"
        type="daterange"
        range-separator="~"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        value-format="yyyy-MM-dd"
        :picker-options="pickerOptions0"
      >
      </el-date-picker>

	data () {
	    return {
	      en_clearable: false,
	      data_value: "",
	      pickerOptions0: {
	        disabledDate(time) {
	          let curDate = new Date().toString(); // 当前时间戳转为字符串
	          // let curDateYear = new Date().getFullYear(); // 当前时间的年份
	          // let oneYearAgoDate = curDate.replace(curDateYear, curDateYear - 1); // 字符串年份替换为一年前
	          // let oneYear = new Date(oneYearAgoDate).getTime(); //一年前字符串转为时间戳
	          let  birthday = new Date("Jan 1, 2017 00:00:00")//起始时间为  2017.1.1
	          let oneYear = birthday.getTime()
	          return time.getTime() > Date.now() || time.getTime() < oneYear;
	          // return time.getTime() < oneYear
	        },
	      },
	    }
	  }

标签:ElementUl,getTime,起始,oneYear,Date,let,time,组件,new
来源: https://blog.csdn.net/DuBanL/article/details/120844801