The problem will disappear when refreshing the page data in vuex

Solution:

    Change the definition of the state of the index file under the store file

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

    And add in App.vue

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

    In other words, listen to the unload method, if you reload the page, store the state in sessionStorage, and then take the value from sessionStorage when the state is needed.

Guess you like

Origin www.cnblogs.com/yxkNotes/p/12751655.html