I'm building out a vuetify/nuxt
frontend for the first time, and I've moved my v-navigation-drawer
component out of the default.vue
layout, and into it's own component, so that it can be reused in multiple layouts.
The activator for this drawer still remains in the default.vue
component, so I added a sidebar
state to vuex:
export const state = () => ({
baseurl: 'http://example.com/api/',
sidebar: false,
authenticated: false,
token: null,
user: null,
})
The mutator for the sidebar looks like so:
export const mutations = {
toggleSidebar(state) {
state.sidebar = !state.sidebar;
}
}
This works perfectly when opening the drawer, but because the drawer is dismissed via clicking the overlay, or clicking off of sidebar (if you've turned the overlay off) vuex throws a huge error:
How can I make this work correctly through vuex?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…