假设我们在xxx.scss
中声明了一个 theme:blue
,我们在 js 中该怎么获取这个变量呢?我们可以通过 css-modules :export
来实现。
// xxx.scss
$theme: red;
:export {
theme: $theme;
}
// test.js
import variables from '@/styles/xxx.scss'
console.log(variables.theme) // red
假设我们在xxx.scss
中声明了一个 theme:blue
,我们在 js 中该怎么获取这个变量呢?我们可以通过 css-modules :export
来实现。
// xxx.scss
$theme: red;
:export {
theme: $theme;
}
// test.js
import variables from '@/styles/xxx.scss'
console.log(variables.theme) // red