Make vuex store globally available with Vue 3 and typescript project built with the cli solved

0 votes

How do I make my store globally available in vue 3 with vuex?

My store:

import { createStore } from 'vuex'

export default createStore({
  state: {},
  mutations: {},
  getters: {},
  actions: {},
  modules: {},
})

My main.ts

import yourStore from './store/yourStore'

const app = createApp(App)
app.use(yourStore)

app.config.globalProperties.$yourStore = yourStore

app.mount('#app')

This doesn't work:

this.$yourStore.dispatch('your action')
Jul 5, 2022 in TypeSript by Nina
• 3,060 points

edited Mar 4 7 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP