I have the following VueRouter route
{
path: '/playlists/:id',
name: 'videos',
component: Video,
props: {
videos: []
},
beforeEnter (to, from, next) {
Vue.axios.get('/playlistitems?playlistId='.concat(to.params.id))
.then((response) => {
to.params.videos = response.data
next((vm) => {
console.log(vm)
vm.videos = response.data
})
})
.catch((err) => console.log('error', err))
}
}
When the route is entered into everything executes as expected but I'm not sure how to pass the response.data
to the route's component Videos
Question 1
- Can you set the Vue component's props property from the Router?
Question 2
- The route is a dynamic route. If the route and component is already loaded and the dynamic parameter changes....does
beforeEnter
still fire? If not where should I put my data fetching logic? Do Iwatch
for route changes inside the Vue component?