4, how to use the class binding style

vue in style (using vue binding style)

The first

Do not use vue styled bind the direct class = "thin active" can

Vue using an array of multiple styles of binding (binding properties using v-bind that is :)

:class=“{‘thin’,‘itatic’,‘active’}”

:class=“{‘thin’,‘itatic’,flag?'active':''}”

So that you can get data from vue, if the flag is true, on the use of active, if not on what is true all the same

:class=“{‘thin’,‘itatic’,{‘active’:flag}}”

Such use this object to be judged to simplify the expression reflects three yuan

The second object

16196576-4d2ff4f375e4eef4.png
1556330989145.png

Vue use inline styles

Internal style unordered collection of key-value pairs

:style=''{color:"red",}''

The same array can be defined as an object

Guess you like

Origin blog.csdn.net/weixin_34235105/article/details/91026135