1、定义variables.scss文件
// base color
$blue:#324157;
$light-blue:#3A71A8;
$red:#C03639;
$pink: #E65D6E;
$green: #30B08F;
$tiffany: #4AB7BD;
$yellow:#FEC171;
$panGreen: #30B08F;
// 默认菜单主题风格
$base-menu-color:#bfcbd9;
$base-menu-color-active:#f4f4f5;
$base-menu-background:#304156;
$base-logo-title-color: #ffffff;
// 用于代码中调用
:export {
menuColor: $base-menu-color;
menuLightColor: $base-menu-light-color;
menuColorActive: $base-menu-color-active;
menuBackground: $base-menu-background;
menuLightBackground: $base-menu-light-background;
menuLightBackgroundMy: $base-menu-light-background-my;
subMenuBackground: $base-sub-menu-background;
subMenuHover: $base-sub-menu-hover;
sideBarWidth: $base-sidebar-width;
logoTitleColor: $base-logo-title-color;
logoLightTitleColor: $base-logo-light-title-color
}
2、在<style>标签中调用
<style lang="scss" scoped>
@import "~@/assets/styles/variables.scss";
.fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: 9;
width: calc(100% - #{$base-sidebar-width});
transition: width 0.28s;
}
.tools-wrap-hidden{
z-index: 1;
position: absolute;
left: $base-sidebar-width + 10;
top: 4em;
display: flex;
flex-direction: column;
}
</style>
3、在其他css文件中调用方式
@import './variables.scss';
4、在代码中调用方式
<div :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackgroundMy }">
<script>
import variables from "@/assets/styles/variables.scss";
export default {
computed: {
variables() {
return variables;
},
}
}
</script>