I\'m using Vue router with two pages:
let routes = [
{
path: \'/\',
component: require(\'./components/HomeView.vue\')
},
{
pa
If the class is view specific, may be this will help
methods: {
toggleBodyClass(addRemoveClass, className) {
const el = document.body;
if (addRemoveClass === 'addClass') {
el.classList.add(className);
} else {
el.classList.remove(className);
}
},
},
mounted() {
this.toggleBodyClass('addClass', 'mb-0');
},
destroyed() {
this.toggleBodyClass('removeClass', 'mb-0');
},
Move the methods
section to a mixin and then the code can be DRY.