Answer the question
In order to leave comments, you need to log in
Vue: App theming like in Vuetify?
Hey guys!)
I'm trying to make theme switching like in Vuetify so that each component has the ability to get the $theme variable via this and set the class to the component, depending on the value of the theme variable.
A variable with a theme must be reactive, and called with a mutation, or some similar option, so that when the variable changes, the theme changes immediately + the new value of the variable must be sent to the server, respectively, through the action.
Here is what I tried:
import Vue from 'vue'
import store from '../store'
const install = (Vue) => {
Vue.prototype.$theme = store.state.theme
}
Vue.use(install)
function vuexInit () {
const options = this.$options
// store injection
if (options.store) {
this.$store = typeof options.store === 'function'
? options.store()
: options.store
} else if (options.parent && options.parent.$store) {
this.$store = options.parent.$store
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question