I'm new to Vuejs and I found this issue when i'm trying to do the hamburger menu function.
To get simplify I have added code spinets below
App.vue
<keep-alive>
<div class="body-wrapper" v-bind:class="menuOpenCls">
<div class="hamburger-wrapper" v-on:click="mobileMenu()">
<div class="hamburger-menu">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
<router-view v-bind:headerMenu="headerMenu" v-bind:footerMenu="footerMenu" v-bind:ShowSmileys="ShowSmileys"></router-view>
</div>
</keep-alive>
...
data() {
return {
menuOpen:''
}
},
...
methods: {
mobileMenu: function() {
this.menuOpen = !this.menuOpen;
}
}
...
computed: {
menuOpenCls: function() {
return this.menuOpen ? 'menuopen' : '';
}
}
Header.vue
<header>
<nav v-if="headerMenu">
<ul class="menu">
<li><router-link v-bind:to="item.Url" exact v-on:click="**<<function to change class on App.vue>>**>{{item.Name}</router-link></li>
</ul>
</nav>
</header>
I want to change (toggle) class name on App.vue (class where body-wrapper is in) depending on click event in Header.vue menu link. How can I achieve this. Can Any one help?