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>