- 凡是有-的style属性名都要变成驼峰式,比如font-size要变成
fontSize
- 除了绑定值,其他的属性名的值要用引号括起来,比如
backgroundColor:'#00a2ff'
而不是 backgroundColor:#00a2ff -
对象
-
html :style="{ color: activeColor, fontSize: fontSize + 'px' }"
html :style="{display:(activeName=='first'?'flex':'none')}"
数组
-
html :style="[baseStyles, overridingStyles]"
html :style="[{display:(activeName=='first'?'flex':'none')},{fontSize:'20px'}]"
三目运算符
-
html :style="{color:(index==0?conFontColor:'#ddd')}"
html :style="[{color:(index==0?conFontColor:'#ddd')},{fontSize:'22px'}]"
多重值
-
html :style="{ display: ['-webkit-box', '-ms-flexbox', 'flex'] }"
Vue中动态设置Style样式
最新推荐文章于 2024-04-18 15:01:57 发布