html
中绑定style:style="menuStyle"
<el-menu-item class="super_menu_item" :style="menuStyle" :index="`/${item.index}`" :key="item.index">
<i :style="{'color':theme.textColor}" :class="item.icon"></i>
<span slot="title">{{ item.title }}</span>
</el-menu-item>
计算属性值返回动态取值
computed: {
menuStyle() {
return {
'--bg-color': this.theme.sidebarColor,
'--bg-color-hover': this.theme.headerColor,
'--text-color': this.theme.textColor
}
}
}
css中绑定颜色
.el-menu-item:hover {
background-color:var(--bg-color-hover) !important;
}