我怎样才能做到这一点?
// 样式.scss
$primary-color: #dc4545;
div{
background : $primary-color;
}
Run Code Online (Sandbox Code Playgroud)
尝试这样做:
div{
background : var(--primary-color)
}
Run Code Online (Sandbox Code Playgroud)
这有可能吗?
您可以在以下位置定义全局变量:root:
:root {
--primary-color: #dc4545;
}
div {
background: var(--primary-color);
}
Run Code Online (Sandbox Code Playgroud)
编辑:或者你试图混合搭配?
$primary-color: #dc4545;
:root {
--primary-color: #{$primary-color};
}
div {
background: var(--primary-color);
}
Run Code Online (Sandbox Code Playgroud)