[Vuejs]-JavaScript.. Use values of local variables in other functions

1πŸ‘

βœ…

You can’t dynamically update the initial theme object used by createVuetify but you can instead have your updateColor() method directly modify $vuetify.theme where the theme colors are made accessible as noted in the documentation

values will also be made available on the instance $vuetify object under the theme property. This allows you to dynamically modify your theme. Behind the scenes, Vuetify will regenerate and update your theme classes, seamlessly updating your application.

// Light theme

this.$vuetify.theme.themes.light.primary = β€˜#4caf50’

// Dark theme

this.$vuetify.theme.themes.dark.primary = β€˜#4caf50’

In your case, the method would look something like this:

updateColor() {
  this.$vuetify.theme.themes.light.primary = this.btn_color
}
πŸ‘€yoduh

Leave a comment