Vue.js 在运行时更改Vuetify 2中主题的主文本颜色
我允许用户通过调用以下命令,使用任何十六进制颜色来更改应用程序的主基色:Vue.js 在运行时更改Vuetify 2中主题的主文本颜色,vue.js,frontend,vuetify.js,Vue.js,Frontend,Vuetify.js,我允许用户通过调用以下命令,使用任何十六进制颜色来更改应用程序的主基色: changeTheme(color){ Vuetify.framework.theme.themes.light.primary = color } 问题是,如果选择的颜色太亮或太暗,文本颜色就无法读取 有这样的事吗?==> changeTheme(color, textColor){ Vuetify.framework.theme.themes.light.primary = color <== Thi
changeTheme(color){
Vuetify.framework.theme.themes.light.primary = color
}
问题是,如果选择的颜色太亮或太暗,文本颜色就无法读取
有这样的事吗?==>
changeTheme(color, textColor){
Vuetify.framework.theme.themes.light.primary = color <== This line works
Vuetify.framework.theme.themes.light.primaryText = textColor <== This not
}
changeTheme(颜色、文本颜色){
Vuetify.framework.theme.themes.light.primary=color我的解决方案
vuetify.js
export default new Vuetify({
icons: {
iconfont: 'md'
},
theme: {
// dark: true,
// theme: { disable: true },
options: { customProperties: true },//add this
themes: {
light: {
primary2: colors.indigo.base,//add this
primary2Text: colors.shades.white//You can also use localStorage.getItem('XXX')
},
dark: {
// primary: colors.blue.lighten3,
background: colors.grey.base
}
}
}
});
vue
appbar先生,
.页脚{
背景色:var(--v-primary2-base)!重要;
颜色:var(-v-primary2Text-base)!重要;
}
我也想知道答案。我正在尝试编写一个组件,允许用户在应用程序中更改某些颜色,文本颜色就是其中之一。
<v-app-bar app class="appbar"></v-app-bar>
.appbar,
.footer {
background-color: var(--v-primary2-base) !important;
color: var(--v-primary2Text-base) !important;
}