style
里面添加样式;style
中添加样式并很差维护(除非真的是本组件特有的样式),由于不少时候,同一个样式会利用在项目中的不少地方,好比一个后台的全部按钮风格都要同样,咱们也不可能每个都去设置一下样式,若是忽然感受颜色不对,岂不是要每一个文件的去修改了,并且有些样式的设置经过这种方式也未必有效(固然其余名字的scss也会有一样的问题,并不老是有效的$--font-path: '~element-ui/lib/theme-chalk/fonts'; @import "~element-ui/packages/theme-chalk/src/index";
element-variables.scss
里添加一条简单的代码,$
的这种写法是scss里对变量的修饰符。el-button
的各类状态下的样式都修改,请按照下面的顺序,这和<a>
标签是相同的道理).add { &.el-button { background-color: #666 !important; border-color: #666 !important; } &.el-button:focus { background-color: #999 !important; border-color: #999 !important; } &.el-button:hover { background-color: #aaa !important; border-color: #aaa !important; } &.el-button:active { background-color: #eee !important; border-color: #eee !important; } }
<style rel="stylesheet/scss" lang="scss" scoped> @import "~@/common/styles/element-variables.scss"; </style>
el-button
中的加上对应的class即可<el-button class="add">添加</el-button>