在script里面,修改css的属性,有两种方法:
1. 动态的设置class类名
<div :class="color"></div>
method: {
setColor() {
this.color = colorRed;
}
}
<style>
colorRed { color: red }
</style>
- 操作dom节点
<div ref='color'></div>
this.$refs.color.style.corlor = red