Vue 2 and Vue-Router 2.
I'm trying to change the color of my app's navbar based on which route is visited. Here's what I have:
main.js:
import App from "../components/App.vue"
const app = new Vue({
router: Router,
template: '<app></app>',
components: { App }
}).$mount('#app')
App.vue:
<template>
<div>
<div class="navbar" v-on:class="{ colorNav: 'color-nav' }"></div>
<router-view></router-view>
</div>
</template>
<script>
export default {
data() {
return {
colorNav: false
}
}
}
</script>
With this setting, since colorNav property is false, the color-nav class is not added to the navbar. Working as intended.
Now the user goes to /somepage, which maps to SomePage.vue, which renders inside router-view. I would like SomePage.vue to change the colorNav property on App.vue so that color-nav class is added to the navbar.
How do I do that?