
定义一个uni.scss变量,然后在App.vue中引入:

在别的组件中使用:直接使用
最好重启项目,不然可能会报错提示说没有这个变量

报错提示没有变量,就重新启动项目,然后就可以了:
plugin:vite:css\] Undefined variable. ╷ 241 │ color: $red-hado; │ \^\^\^\^\^\^\^\^\^ ╵ src/pages/home/index.vue 241:36 root stylesheet at pages/home/index.vue:1:0 Error: Undefined variable. ╷ 241 │ color: $red-hado; │ \^\^\^\^\^\^\^\^\^ ╵ src/pages/home/index.vue 241:36 root stylesheet