1.直接在元素上通过:style绑定书写
<h1 :style="{color: 'red','font-size': '40px'}">这是一个h1文本</h1>
2.将样式对象定义到data中,并直接引用到:style中
data:{ style1:{color: 'red','font-size':'40px'} }
data:{
style1:{color: 'red','font-size':'40px'}
}
html:
<h1 :style="style1">这是一个h1文本<h1>