Categories
Vue Answers

How to access a Vuex store outside of a component in Vue.js?

Spread the love

Sometimes, we want to access a Vuex store outside of a component in Vue.js.

In this article, we’ll look at how to access a Vuex store outside of a component in Vue.js.

How to access a Vuex store outside of a component in Vue.js?

To access a Vuex store outside of a component in Vue.js, we can import the store and use it directly.

For instance, we write

import { store } from "./store";

store.getters.appSettings

to import the store with

import { store } from "./store";

Then we get the value of the appSettings getter with

store.getters.appSettings

Conclusion

To access a Vuex store outside of a component in Vue.js, we can import the store and use it directly.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *