uniapp + vue3 + scss 定义全局样式变量,并使用
·

定义一个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
更多推荐
所有评论(0)