After the data vue vuex Refresh Data Loss

app page
  Created () {
     // read page load status information in sessionStorage 
    IF (sessionStorage.getItem ( "Store" )) {
       the this . $ store.replaceState ( 
        Object.assign ( 
          {}, 
          the this . $ store.state, 
          the JSON.parse (sessionStorage.getItem ( "Store" )) 
        ) 
      ); 
    } 
    // a page refresh to save the information in the vuex sessionStorage in 
    window.addEventListener ( "beforeunload", () => { 
      sessionStorage.setItem ( " Store "," " ); 
      sessionStorage.setItem ( " Store ", JSON.stringify ( the this $ store.state.));
    });
  }

Guess you like

Origin www.cnblogs.com/chen-yi-yi/p/12161607.html