0

For my current project we have a single navbar.vue that is placed in a components folder. Then all our pages are listed under the layouts folder. Currently the vue app is ran by the main.js file that places the navbar on each page. Is it possible to have different data on each page that is shown in the navbar, but then these piece of information can also be treated as event clicks and toggle reactions on each page?

1 Answer 1

1

This is was vuex was made for.

Your shared application state resides in a store that manages reactivity between components.

https://vuex.vuejs.org/guide/

You would get your data from the $store in you navbar and components.


I like to view the refactoring of data in vue as such:

First data in, and private to, a component

Then props passed in from parent

Then events emitted from child to parent (child never mutates data passed in, so it sends events up instead)

Then $store/state from vuex to go beyond when this parent/child model starts to fall apart.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.