1、 定义变量
bgColor:{
type:String,
default:"#45A8ED"
}
2、template 中引入
<span :style="{'--bgColor':bgColor}">{{item}}</span>
3、css中写入
.cs{
background-color: var(--bgColor);
padding: .208333rem .35rem;
border-radius: .208333rem;
font-family: "DIN-Bold";
margin-right:.3125rem
}

本文介绍了在Vue项目中如何定义和使用SCSS变量,包括在组件的data中声明变量,然后在template模板和CSS样式中引用这些变量,实现样式动态化和代码复用。
597

被折叠的 条评论
为什么被折叠?



