[Vuejs]-How to route dynamic content?

0👍

In most cases, the data comes from a remote server, you can use your component to make an AJAX call and store the result however a better approach will be to use VUEX as a centralized state – with this approach you will also be able to use the author data across multiple components without the need to pass it over and over.

To make it clear, your route should have a parameter to identify the selected author (surname, id, whatever) – you do that with :surname when specifying the route. Then your component is loaded and read the parameter from the route this.$route.params.surname then use it to load the data from a remote server / vuex

0👍

In my opinion you don’t need vuex you need a parent component (maybe layout) that gets the data has a computed property which it passes to the child component, the computed property is the data you want, it will update when your child component emits a change that triggers an event to change one of it’s dependencies.
So basically parent handles data passes down to child and changes based on events emitted from child.

Leave a comment