I'm using Nuxt.js v2.12.2 with Vuetify. I installed Vuetify during the initial configuration of the new project.
I want to build a static website with some functionality like change the theme from dark to light.
So I added a switch in my default layout to change this property: $vuetify.theme.dark
Here's my code for the switch:
<v-switch v-model="$vuetify.theme.dark" />
I even tried in this way but is the same:
<v-switch @click="$vuetify.theme.dark = !$vuetify.theme.dark" />
When I click on the switch the property change correcly. But if I change page or I reload, it goes back to his previous value.
How do I change this property so that it stays that way for the session? Do I need to save it somewhere?
Here's the code inside nuxt.config.js:
vuetify: {
customVariables: ['~/assets/variables.scss'],
theme: {
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
},
light: {
primary: '#3f51b5',
secondary: '#b0bec5',
accent: '#8c9eff',
error: '#b71c1c',
},
}
}
Thanks for the help.