problem scenario
sass version: 1.52.1
When using Sass/Scss variables in custom properties of CSS Variables
This way of writing won't work as expected
$primary: #409eff;
:root {
--fill-color-primary: $primary;
}
// 编译后 css,变量没有成功应用 ↓
:root {
--fill-color-primary: $primary;
}
solution
The reason is that the syntax of Sass has changed
Breaking Change: CSS Variable Syntax
...to provide maximum compatibility with plain CSS, newer versions of Sass require SassScript expressions in custom property values to be written in interpolation ...
$primary: #409eff;
:root {
--fill-color-primary: #{$primary};
}
// 编译后 css
:root {
--fill-color-primary: #409eff;
}
Extended reading
sass interpolation
Similar to template string interpolation in ES6 ${}
;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。