I'm struggling with transferring props between children and parent components using Vue Routes. Within my Layout component, I have a wrapper DIV structured like this:
<template>
<div class="container" v-bind:class="cssClass">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'Layout',
props: ['cssClass']
}
</script>
In my base App JS file, I have defined my routes as shown below. Initially, the view loads with the class "container-animated" and everything works perfectly.
const router = new VueRouter({
routes: [
{ path: '/', component: Layout, props: { cssClass: 'container-animated' },
children: [
{ path: '', component: Homepage },
{ path: '/hello-world', component: HelloWorldPage, props: { cssClass: '' } }
]
},
]
});
However, when navigating to the /hello-world route, I want to pass an empty cssClass prop down to Layout (where HelloWorldPage is nested). How can I achieve this? Is using props the right approach?