With Vuetify 2.0, I would like to propose my solution:
Vuetifty Theme Referance
Follow the documentation as usual with setting up custom theming, except add another variable (background in my case).
import Vue from 'vue'
import Vuetify from 'vuetify/lib'
import colors from 'vuetify/lib/util/colors'
const vuetify = new Vuetify({
theme: {
themes: {
light: {
primary: colors.purple,
secondary: colors.grey.darken1,
accent: colors.shades.black,
error: colors.red.accent3,
background: colors.indigo.lighten5, // Not automatically applied
...
},
dark: {
primary: colors.blue.lighten3,
background: colors.indigo.base, // If not using lighten/darken, use base to return hex
...
},
},
},
})
But we are not done! The background
variable doesn't cut it. We need to rig v-app
to toggle the light/dark backgrounds.
<template>
<v-app id="main" :style="{background: $vuetify.theme.themes[theme].background}">
<v-content>
Stuff :)
</v-content>
</v-app>
</template>
<script>
export default {
name: 'App',
computed:{
theme(){
return (this.$vuetify.theme.dark) ? 'dark' : 'light'
}
}
};
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…