1 - Create a snackbar plugin receiving vuex store as option:
// src/plugins/snackbar.jsconstsnackbarPlugin={install:(Vue,{store})=>{if(!store){thrownewError('Please provide vuex store.');}Vue.prototype.$snackbar={showMessage:function({content='',color=''}){store.commit('snackbar/showMessage',{content,color},{root:true});}};},};exportdefaultsnackbarPlugin;
For those using vue and dont have Nuxt inject:
1 - Create a snackbar plugin receiving vuex store as option:
2 - At your main.js, pass your plugin to Vue:
Thanks for this. I added link for this comment on post for other people who doesn't use Nuxt.