【发布时间】:2019-05-09 13:59:51
【问题描述】:
如何覆盖 vuetify 中的实际类?
我创建了一个 ./src/stylus/main.styl 文件,我在其中覆盖了一些当前的 vuetify 设置作为测试:
@import '~vuetify/src/stylus/settings/_variables'
@import '~vuetify/src/stylus/elements/_typography'
$material-dark.background = green
$body-font-family = Arial
$alert-font-size = 18px
.display-2
font-size: $headings.h6.size !important
font-family: $headings.h3.font-family !important
@import '~vuetify/src/stylus/main'
由于某种原因,上述值仅部分起作用。分配给$material-dark.background 和$body-font-family 的新值适用于theme--dark 下的任何内容,但是当涉及.display-2 时,这些值仍然调用font-size 和font-family 的原始设置并覆盖这些值我添加到 main.styl。我什至尝试进入包含.display-2的组件,首先在手写笔中作为范围语言不起作用,然后在普通css中不会引发错误,但会被Vuetify在app.xxx.css和块中生成的原始默认值覆盖-vendor.xxx.css 文件。
//component
<style scoped>
h1.display-2{
font-size:20px;
font-family: "Times New Roman";
color:green;
}
</style>
这是有原因的吗?
【问题讨论】:
-
可能相关,请务必阅读所有 cmets:stackoverflow.com/q/53191552/1981247
-
我的应用文件中没有预设样式。
-
我将
main.styl的代码修改为:h1.display-2 font-size: 30px!important font-family: Times New Roman!important color:$indigo.base。但是我发现将 "!important!" 添加到所有混乱中。有什么更简洁的方法来覆盖样式值?
标签: vue.js vuetify.js stylus vue-cli-3