注意:
凡是有-的style属性名都要变成驼峰式,比如font-size要变成fontSize
除了绑定值,其他的属性名的值要用引号括起来,比如backgroundColor:'#00a2ff’而不是 backgroundColor:#00a2ff
对象绑定:
html :style="{ color: activeColor, fontSize: fontSize + 'px' }"
html :style="{color:(index==0?conFontColor:'#000')}"
数组绑定:
html :style="[baseStyles, overridingStyles]"
html :style="[{color:(index==0?conFontColor:'#000')},{fontSize:'20px'}]"
三目运算符:
html :style="{color:(index==0?conFontColor:'#000')}"
html :style="[{color:(index==0?conFontColor:'#000')},{fontSize:'20px'}]"
多重值:
html :style="{ display: ['-webkit-box', '-ms-flexbox', 'flex'] }"
绑定data对象:
html :style="styleObject"
data() {
return{
styleObject: {
color: 'red',
fontSize: '13px'
}
}
}