Between vuex --- brothers components by value

Description of Requirement:

FIG follows: TopHeader assembly needs to acquire the menu name leftNav click menu, when leftNav click menu, the corresponding menu name displayed in the topHeader

Solution:

Means vuex, the solution the steps of:

1, the installation vuex, command [npm install vuex --save]

2, create a store: In [src] directory project under the New Folder New store [store] and [] [] index.js. Initialization state object. [CurrentMenu] variable is used to store the name of the menu currently displayed page.

3, registered in the [store] in main.js 

4, leftNav assembly method defined click menu, and passed to the state store.js currentMenu object [] variable in the process parameters in the menu name

5, is introduced in the assembly topHeader] [currentMenu

 

Published 147 original articles · won praise 33 · views 30000 +

Guess you like

Origin blog.csdn.net/maidu_xbd/article/details/103281157