解决办法:

    更改store文件下index文件state的定义

const store = new Vuex.Store({
    state:sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')): {
        //id
        skillId:'',
        //技能状态
        checkStatus:''
    }
})

    以及在App.vue中添加

     mounted() {
            window.addEventListener('unload', this.saveState)
        },
        methods: {
            saveState() {
                sessionStorage.setItem('state', JSON.stringify(this.$store.state))
            }
        }

    也就是说监听unload方法,如果重载页面就把state存入sessionStorage,然后在需要state的时候从sessionStorage中取值。

相关文章:

  • 2021-09-11
  • 2021-07-30
  • 2021-09-22
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-21
  • 2021-04-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案