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

// 进入当前路由拿数据
  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()
  }

 

posted on 2021-06-15 16:24  章画  阅读(77)  评论(0编辑  收藏  举报

导航