javascript - Ask for advice on value transfer between Vue2 components
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:34:13
0
3
559

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?

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
巴扎黑

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

迷茫

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

巴扎黑

/a/11...
The second part of an article I wrote before [2. Practical project development]
Hope it can help you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template