vue class添加样式

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 :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},

}