// html 模板 template
<span class="red" :style="styleVar" @click="add">as</span>
// js
data() {
return {
styleVar: {
"--colorBlue": "blue",
"--colorRed": "red",
"--fontSize": "30px",
"--fontSizeTest": "30px",
},
size: 30
};
},
// methods
add () {
this.size++
this.styleVar['--fontSize'] = this.size + 'px'
}
// css
.red {
color: var(--colorRed);
font-size: var(--fontSize);
}
vue使用css变量
猜你喜欢
转载自blog.csdn.net/qq_43505774/article/details/113500122
今日推荐
周排行