进入特定页面才会缓存页面数据

// 进入当前路由拿数据
  beforeRouteEnter (to, from, next) {
    next(vm => {
    // 通过 `vm` 访问组件实例
      if (from.path === '/pa') {
        const { groupValue, queryPaymentBillParamModelList, isRead } = JSON.parse(sessionStorage.getItem('dd'))
        vm.queryPaymentBillParamModelList = queryPaymentBillParamModelList
        vm.groupValue = groupValue
        vm.isRead = isRead
      } else sessionStorage.removeItem('dd')
    })
  },
  // 出当前路由存数据
  beforeRouteLeave (to, from, next) {
    if (to.path === '/pa') {
      const data = {
        queryPaymentBillParamModelList: this.queryPaymentBillParamModelList,
        groupValue: this.groupValue,
        isRead: this.isRead

      }
      sessionStorage.setItem('dd', JSON.stringify(data))
    }
    next()
  }
原文地址:https://www.cnblogs.com/xiaoliziaaa/p/14886010.html