在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue頁面緩存之后,再回到之前頁面,時間組件報錯

vue頁面緩存之后,再回到之前頁面,時間組件報錯

設(shè)置緩存

handleShow (card) {
        if (!this.form.activityEndTime) {
          this.$message.error("請先選擇活動結(jié)束時間");
          return ;
        } else if (this.selectTicket.length < 10){
          this.$refs.dialog.show(null, this.form.activityEndTime);
        } else {
          this.$message.error("最多只能添加10張優(yōu)惠券");
        }
        localStorage.setItem("activitySaved",JSON.stringify(this.form));
        let test = JSON.parse(localStorage.activitySaved);
        console.log(test);
      },

通過特定頁面進入讀取緩存

 beforeRouteEnter (from, to, next) {
      next(vm => {
        if (to.path.includes('/MarketingManage/Coupon/AddCoupon')) {
          if (localStorage.getItem('activitySaved')){
            vm.form = JSON.parse(localStorage.activitySaved);
            console.log(2,vm.form.activityStartTime);
          }
        }
      });
    },

讀取之后

clipboard.png

return {
      startPickerOptions: {
        disabledDate (currentDate) {
          console.log(2,_this.form.activityStartTime);
          return _this.$moment().startOf('days').valueOf() > currentDate.getTime()
            || (_this.form.activityEndTime && currentDate.getTime() > _this.form.activityEndTime.getTime());
        }
      },
      endPickerOptions: {
        disabledDate (currentDate) {
          return (_this.$moment().startOf('days').valueOf() + 86400000) > currentDate.getTime()
            || currentDate.getTime() <= _this.form.activityStartTime.getTime() - 86400000;
        }
      },
      startTime: minutes >= 30 ? _this.$moment().add(1, 'hours').format('HH:00') : _this.$moment().format('HH:30'),
      endTime: '00:00',
      commitStatus: true
    };
  },
回答
編輯回答
尛憇藌

因為你從localstorage里取出來的activityStartTime只是個字符串,不是個Date對象了

2018年3月1日 08:59