实现侧边栏颜色的整体修改
组件代码
html
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu
:default-active="activeMenu"
:collapse="isCollapse"
:background-color="variables.menuBg"
:text-color="variables.menuText"
:unique-opened="true"
:active-text-color="variables.menuActiveText"
:collapse-transition="false"
mode="vertical"
>
<sidebar-item
v-for="route in routers"
v-show="route.meta && route.meta.types && route.meta.types.indexOf(routeMetaType) > -1"
:key="route.path"
:item="route"
:base-path="route.path"
/>
</el-menu>
</el-scrollbar>
导入样式代码
javascript
import variables from '@/styles/variables.scss'
样式目录
样式代码
javascript
// sidebar
$menuText:#545c64;
$menuActiveText:#298dff;
$subMenuActiveText:#298dff; //https://github.com/ElemeFE/element/issues/12951
$menuBg:#F6F7F8;
$menuHover:rgba(4,204,137,.1);
$subMenuBg:#F6F7F8;
$subMenuHover:rgba(4,204,137,.1);
$sideBarWidth: 210px;
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
:export {
menuText: $menuText;
menuActiveText: $menuActiveText;
subMenuActiveText: $subMenuActiveText;
menuBg: $menuBg;
menuHover: $menuHover;
subMenuBg: $subMenuBg;
subMenuHover: $subMenuHover;
sideBarWidth: $sideBarWidth;
}