Demand background

Two pages A and B. When page B is closed, page A is notified to request the interface to refresh the list page


Use the storage event to communicate with the page, and specify the communication key. Here, we assume that the key is refresh_list

A listens to storage events

mounted() {
  window.addEventListener('storage', this.otherWindowListener, false);
  this.$on('hook:beforeDestroy', () => {
    window.removeEventListener('storage', this.otherWindowListener);
methods: {
  otherWindowListener(event) {
    if (event.key === 'refresh_list'{/ /dosomething }; }},Copy the code

B. When saving the Settings, set the localStorage key and close the page

methods: {
  close() {
    localStorage.setItem('refresh_list', new Date().getTime()); try { window.close(); } catch (e) { console.log(e); }}},Copy the code