我启用了自定义属性:
Vue.use(Vuetify, {
options: {
customProperties: true
}
});
并试图通过CSS变量使用:
<style>
.custom{
color:var(--v-primary-base);
}
</style>
这是我设置主题的vuetify.js
文件:
export default new Vuetify({
icons: {
iconfont: 'mdi',
},
theme: {
themes: {
light: {
background: '#FFFFFF',
primary: '#25316A',
secondary: '#b0bec5',
accent: '#25316A',
error: '#E86674',
orange: '#FF7A0D',
golden: '#A68C59',
badge: '#F5528C',
customPrimary: '#085294',
},
dark: {
primary: '#085294',
}
},
},
})
所有主题颜色都不能通过变量访问。我尝试了很多方法,但都没有奏效,也没有出现错误。有人能帮我吗?
发布于 2020-03-24 11:33:15
您需要将options
属性传递给Vuetify
实例,而不是在use
函数中传递而不是。
来自文档
export default new Vuetify({
theme: {
options: {
customProperties: true,
},
// ...
},
})
发布于 2020-07-21 14:26:36
你必须在vuetify文件中使用选项,但是你在错误的地方使用了它,就像这样.
export default new Vuetify({
icons: {
iconfont: 'mdi',
},
theme: {
options: {
customProperties: true,
},
themes: {
light: {
background: '#FFFFFF',
primary: '#25316A',
secondary: '#b0bec5',
accent: '#25316A',
error: '#E86674',
orange: '#FF7A0D',
golden: '#A68C59',
badge: '#F5528C',
customPrimary: '#085294',
},
dark: {
primary: '#085294',
}
},
},
})
在此之后,当您想使用您的自定义CSS变量时,您必须像这样使用它。
<style>
.custom{
color:var(--v-golden-base);
}
</style>
这里的底部是一个默认的,我为金色变量展示了,但是您可以使用它们中的任何一个。
https://stackoverflow.com/questions/59529101
复制相似问题