首页 > 解决方案 > 如何在 vite2 和 vue 的 js 中使用 $red、$bgColor 等 scss 变量?

问题描述

当我使用 webpack 从 scss 导入变量时:

/* variable.scss*/
$red:'#123456'
:export{
    navibarText:$red
}

我可以导入它并在javascript中使用:

import variables from '@/styles/variables.scss'
console.log(variables.$navibarText)

我无法在 vite 的 javascript 中正确导入 scss 并使用它,如何在 vite2 和 vue 的 js 中使用 $red、$bgColor 等 scss 变量?

标签: javascriptcsssassvite

解决方案


推荐阅读