vue dynamic way to add style

One,

<li v-for="(chatting,index) in item" :key="index" :class="{'user_right':chatting.user_id}">
User_id determine whether there chatting, if you have additional user_right class name
two,
<p :class="coms===1?'hear1':'hear'"></p>
Judge coms is equal to 1, if it is equal to the additional hear1 class name or class name appended hear
 

Guess you like

Origin www.cnblogs.com/xiao-wu-gui/p/12155498.html