Solved: Vuex actions this.$
-
Good Evening!
I’ve been working on converting our app over to the newest .15 version that was released. I had a question come up thought that I’m curios on how y’all handle it. I’m fairly new to Vue as well so may be a basic question.
Prior to .15 I was throwing axios and a few other general items into the window, now I’m trying to use them inside a plugin. Inside of my “auth” store actions.js file I’m trying to access some functions included in some of the plugin files. For example “this.$axios”. I can access these easily from the pages or components folders just not from anything inside the stores folder. Should I be accessing it differently? Heres what I’ve tried:
Vue.$axios
Vue.prototype.$axiosAgain probably something simple but racking my brain on this one!
-
Yeah I was over thinking it I guess. All I had to do was import Vue and all my prototype methods were then available. I didnt think it would work like this because I was assuming it would create a new instance of Vue and not have the same setup as the initial/main instance.
-
Couple ways to go about it. One is to add a named export to your plugins and import that in stores. Another is to pass the vue instance to the store when dispatching actions
Edit:
You can access the vue instance from the store usingthis._vm