Switching menu, two single-page exhibit the same, real-time updates data manipulation

Some menu business logic processing, record it here:

Business scenario : two menus, navigation display the main menu (the Company), the left side of the menu tree (statements show), through the main menu to select the rendering on the left menu tree, different companies there may be the same (show) a single page

A different route, the navigation menu switch, the left loading menu tree, the same one-page presentation, but a different route, then listens for Router

watch:{
  $route(to,from){
    console.log(to.path);
    //do something
  }
},

Second, the same route, the navigation menu switch, loading navigation tree, exhibit the same single page, the same route, then monitor the current menu navigation menu id

computed: { 
  CurrentID () { 
    return  the this $ store.state.currentId;.  // ID of the current navigation menu 
  } 
}, 
Watch: { 
  CurrentID (newVal, oldVal) { 
    // do something 
  } 
},

 

 

Guess you like

Origin www.cnblogs.com/lhjfly/p/11792232.html