用vue写 style时,
:style="{background-color:o.value}"这个报错了,正确写法是
:style="{'background-color':o.value}"
下面附上:style的用法
一 ,最通用的写法
<p :style="{fontFamily:arr.conFontFamily,color:arr.conFontColor,backgroundColor:arr.conBgColor}">{{con.title}}</p>
二, 三元表达式
<a :style="{color:(index==0?arr.conFontColor:‘#000‘)}" :href="con.subTitleHref" target="_self">{{con.subTitle}}</a>
一和二 可以联合起来写 如下
<p :style="{fontFamily:arr.conFontFamily,fontSize:(arr.conFontSize!=0.36?arr.conFontSize+arr.conFontUnit:‘‘),color:arr.conFontColor,backgroundColor:arr.conBgColor}">{{con.title}}</p>