vue+elementui 只能选7天内的日期

html: 

   查询时间
      
        
        
        
      

js:

 data() {
    const _this = this;
    const dateScope = 7 * 24 * 3600 * 1000;
    return {
     pickerStart: {
        disabledDate(time) {
          const endLen = _this.endDate;
          if (endLen === 0 || endLen == "" || endLen === null) {
            return time.getTime() > Date.now();
          }
          const date = new Date(endLen).getTime();
          // 返回小于7天的,或都返回当前时间减去7天的
          return time.getTime() > date || time.getTime() < date - dateScope;
        }
      },
      pickerEnd: {
        disabledDate(time) {
          const startLen = _this.startDate;
          if (startLen === 0 || startLen == "" || startLen === null) {
            return time.getTime() > Date.now();
          }
          const date = new Date(startLen).getTime();
          return time.getTime() < date || time.getTime() > date + dateScope;
        }
      },
     }

 

你可能感兴趣的:(element,vue2.0)