Project Address: Link Description
Currently there are 3 componentsheaders, Footers, UserList
Among themheaders
{{title}}
In order to display the page title
, I want to change the title
data of headers
by accessing other components. What are the methods? Can you give an example?
It seems that router, vuex and Vue itself can implement it, but I just don’t know how to do it.
Also, please take a look at app.vue
and router/index.js
, the headers and Footers inside , UserList
, what is their relationship? Does UserList
belong to their subcomponents?
巴扎黑2017-05-19 10:36:13
The implementation using vuex is:
Extract the title of the header as an attribute of the state, define a getter to obtain the title, and define a mutation. When you access other components, commit this mutation, and the payload of the mutation is the specific value of the title
迷茫2017-05-19 10:36:13
If you think vuex can’t understand it, then separate the method of refreshing data and put it on the parent component, or make a global refresher yourself
巴扎黑2017-05-19 10:36:13
/a/11...
The second part of an article I wrote before [2. Practical project development]
Hope it can help you