body .thin{
color:red
}
1.數組的形式添加樣式
.<div :class='["thin","title"]'>ddddddddd</div>
2.數組中使用三元表達式
.<div :class='["thin","title",isactive?"active":""]'>ddddddddd</div>
data中定義isactive:true,
3.數組中使用對象
active是類名字
.<div :class='["thin","title",{'active':isactive}]'>ddddddddd</div>
4.直接使用對象
前面是類名為true 使用
<h1 :class=“{red:true,italic:true}”></h1>
通過屬性綁定的形式,將樣式對象應用到元素中
<h1 :style=“{color:"red",“font-weight”:200}”>這是一個H1</h1>
<h1 :style=“h1styleobj”>這是一個H1</h1>
data:{
h1styleob:{color:"red",“font-weight”:200}
}
可以是2個對象
<h1 :style=“[styleobj1,styleobj2]”>這是一個H1</h1>
data:{
h1styleob:{color:"red",“font-weight”:200},
h1styleob:{color:"red",“font-weight”:200},
}