I am trying to change theme dynamically in vueJs, I'll get color code from API, and I want to change theme according to that.
right now I've done like this.
in util.js
var ChangeTheme = {
applyTheme_fn(color) {
document.querySelector(".navbar .navbar-collapse").style.color = color
...
}
}
export default ChangeTheme
in home.vue
import ChangeTheme from '@/components/util.js'
....
methods: {
someMethod() {
let themeColor = data.response.themeColor // color code from API response
ChangeTheme.applyTheme_fn(themeColor)
}
}
This works at some places, but not in all places. If I write style in particular component it works there. but querySelector is not applying at all places.
is there any workaround for this?