After the vue page is cached, go back to the previous page, and the time component reports an error

set cache

handleShow (card) {
        if (!this.form.activityEndTime) {
          this.$message.error("");
          return ;
        } else if (this.selectTicket.length < 10){
          this.$refs.dialog.show(null, this.form.activityEndTime);
        } else {
          this.$message.error("10");
        }
        localStorage.setItem("activitySaved",JSON.stringify(this.form));
        let test = JSON.parse(localStorage.activitySaved);
        console.log(test);
      },

enter the read cache through a specific page

 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);
          }
        }
      });
    },

after reading

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
    };
  },
Mar.02,2021

because the activityStartTime you took out of localstorage is just a string, not a Date object

.
Menu