I just begun working with vuex, i came to a point where i had to use vue instance inside vuex. I was using a package called vue-toasted and to use to it inside vue application and wrote the following code inside main.js
import Toasted from 'vue-toasted';
const ToastedOptions = {
position: 'bottom-center',
duration: 1500,
theme: 'bubble'
};
Vue.use(Toasted, ToastedOptions);
This worked fine inside .vue files. but was not working inside store.js.
Then i tried declaring same code inside store.js, which i didn't work either. I had to access the vue instance, so i came up with a couple of solutions:
- Passing the vue instance as payload to the actions
- Directly accessing vue instance through this._vm
Both pattern worked perfectly, but there must be a better way of doing that, a cleaner approach for clean code.