ElementUI如何修改el-cascader的默認(rèn)樣式
ElementUI如何修改el-cascader的默認(rèn)樣式
Element UI 中的下拉彈窗是通過在整個(gè)body標(biāo)簽?zāi)┪矂?dòng)態(tài)添加div實(shí)現(xiàn)的,所以修改樣式時(shí),必須要定義全局樣式才能實(shí)現(xiàn)樣式覆蓋,那怎樣才能避免全局的樣式污染呢?
解決辦法:通過給組件添加自定義的 popper-class 屬性來避免全局樣式污染;
<el-cascader
v-model="showOptions"
style="height: 36px;width:260px"
placeholder="顯示選項(xiàng)"
:options="optionsList"
:props="props"
collapse-tags
clearable
popper-class="dropDownPanel"
></el-cascader>
下拉框的樣式設(shè)置:
<style>
.dropDownPanel{
background: #123493;
border: 1px solid rgba(57,106,254,1);
}
.dropDownPanel[x-placement^=bottom] .popper__arrow {
display: none;
}
.dropDownPanel .el-cascader-menu {
color: #fff;
border-right: 1px solid rgba(57,106,254,1);
}
.dropDownPanel .el-cascader-node.in-active-path {
color: #38B4C1;
/* background: transparent; */
}
.dropDownPanel .el-cascader-node.is-active {
color: #38B4C1;
}
.dropDownPanel .el-cascader-node:not(.is-disabled):focus,
.dropDownPanel .el-cascader-node:not(.is-disabled):hover {
background-color: #0C0F56!important;
}
</style>
樣式修改
<style scoped>
/deep/ .el-tag.el-tag--info {
background-color: #123493;
border-color: rgba(57,106,254,1);
color: #FFFFFF;
}
/deep/ .el-cascader__tags .el-tag:not(.is-hit) {
border-color: rgba(57,106,254,1);
}
</style>補(bǔ)充:
ElementUI 修改默認(rèn)樣式的幾種辦法
ElementUI 是一套u(yù)i組件庫,目前最新版本 react 和 vue 等主流框架都有支持。該庫默認(rèn)主題色是天藍(lán)色,若用于項(xiàng)目開發(fā),難免遇到要需求修改其默認(rèn)樣式的情況,本文就基于vue 框架介紹幾種修改 ElementUI 默認(rèn)樣式的辦法。
面試官會(huì)問:怎樣修改ElementUI的默認(rèn)樣式 ?
如何修改ElementUI樣式?
回答:一共有三種方法:
1、內(nèi)嵌法修改樣式、通過:style修改,用于局部組件塊
2、:class引用修改樣式,通過:class修改,用于局部組件塊
3、import導(dǎo)入修改樣式
通過import導(dǎo)入樣式文件,若在main.js中導(dǎo)入css 則表示全局引用。既可以用于局部組件塊也可以用于全局組件
deep 穿透
一、內(nèi)嵌法修改樣式
通過:style修改,用于局部組件塊
<el-button :style="selfstyle">默認(rèn)按鈕</el-button>
<script>
export default {
data() {
return {
selfstyle: {
color: "white",
marginTop: "10px",
width: "100px",
backgroundColor: "cadetblue"
}
};
}
}
</script>二、:class引用修改樣式
通過:class修改,用于局部組件塊
<el-button :class="[selfbutton]">默認(rèn)按鈕</el-button>
<script>
export default {
data() {
return {
selfbutton: "self-button"
};
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
.self-button {
color: white;
margin-top: 10px;
width: 100px;
background-Color: cadetblue;
}
</style>三、import導(dǎo)入修改樣式
通過import導(dǎo)入樣式文件,若在main.js中導(dǎo)入css 則表示全局引用。既可以用于局部組件塊也可以用于全局組件
<el-button>和下面的el-button效果一樣</el-button>
<el-button :class="[selfbutton]">默認(rèn)按鈕</el-button>
<script>
import './button.css'
export default {}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped></style>
/* button.css */
.el-button {
color: white;
margin-top: 10px;
width: 100px;
background-Color: cadetblue;
}
.self-button {
color: white;
margin-top: 10px;
width: 100px;
background-Color: cadetblue;
}
.self-button:hover {
color: black;
background-Color: whitesmoke;
}
</style>以上就是我針對(duì)vue框架下的ElementUI 修改默認(rèn)樣式的方法
到此這篇關(guān)于ElementUI如何修改el-cascader的默認(rèn)樣式的文章就介紹到這了,更多相關(guān)ElementUI修改el-cascader默認(rèn)樣式內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解vuex持久化插件解決瀏覽器刷新數(shù)據(jù)消失問題
這篇文章主要介紹了詳解vuex持久化插件解決瀏覽器刷新數(shù)據(jù)消失問題,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-04-04
Vue 實(shí)現(xiàn)CLI 3.0 + momentjs + lodash打包時(shí)優(yōu)化
今天小編就為大家分享一篇Vue 實(shí)現(xiàn)CLI 3.0 + momentjs + lodash打包時(shí)優(yōu)化,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-11-11
vue移動(dòng)端項(xiàng)目緩存問題實(shí)踐記錄
最近在做一個(gè)vue移動(dòng)端項(xiàng)目,被緩存問題搞得頭都大了,積累了一些經(jīng)驗(yàn),特此記錄總結(jié)下,分享到腳本之家平臺(tái),對(duì)vue移動(dòng)端項(xiàng)目緩存問題實(shí)踐記錄感興趣的朋友跟隨小編一起看看吧2018-10-10
Vue3實(shí)現(xiàn)簡約型側(cè)邊欄的示例代碼
本文主要介紹了Vue3實(shí)現(xiàn)簡約型側(cè)邊欄的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07
vue3組合式API實(shí)現(xiàn)todo列表效果
這篇文章主要介紹了vue3組合式API實(shí)現(xiàn)todo列表,下面用組合式?API的寫法,實(shí)現(xiàn)一個(gè)可新增、刪除的todo列表效果,需要的朋友可以參考下2024-08-08
解決Vue 刷新頁面導(dǎo)航顯示高亮位置不對(duì)問題
這篇文章主要介紹了解決Vue 刷新頁面導(dǎo)航顯示高亮位置不對(duì)問題,本文圖文實(shí)例相結(jié)合給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12

