馃摎 What are you trying to do? Please describe.
I wanted to use vuex store with module mode in nuxtjs. but I couldn't access vuex state of store from context.
馃攳 What have you tried?
My code is like below but I couldn't access state.
Have you looked through the docs? Tried different approaches? The more detail the better.
setup(_, { root }: SetupContext) {
const theme = computed(() => root.$store.state.global.theme)
return {theme}
}
By the way, I can make it true with @vue/composition-api.
鈩癸笍 Additional context
I use "@nuxtjs/composition-api": "^0.12.5".
I also use SetupContext type from "@vue/composition-api" installed in "@nuxtjs/composition-api": "^0.12.5"
Try this:
import { useContext } from '@nuxtjs/composition-api'
export default {
setup() {
const { app: { store } } = useContext()
const theme = computed(() => store.state.global.theme)
return { theme }
}
}
I got it. I can't use secound arguemnt in setup as context.
It works now. Thank you
Most helpful comment
Try this: