If (sessionStorage.getitem ("store")) {this.$store.replacestate (object.assign ({}, this.$store.state, JSON. Parse (sessionStorage. The getItem (" store ")))) sessionStorage. RemoveItem (" store ")} / / when the refresh the page to save the information in the vuex sessionStorage window.addEventListener("beforeunload",()=>{ sessionStorage.setItem("store",JSON.stringify(this.$store.state)) })Copy the code