Vue 行内样式写法总结
1.三元表达式
<div :style="{'color':(true?'red':'green')}">写法一</div>
<div :style="true ? 'color:red':'color:blue'" >写法二</div>
<div :style="{opacity:true?1:0 }">写法三</div>
<div :style="{margin: num+'px' }">写法四</div>
2.对象写法 模板字符串
<div :style="{color:`${color}`}">写法一</div>
<div :style="{color:`${true?'red':'green'}`}">写法二</div>
Vue 动态:class写法总结
1.三元表达式
<div clas="name" :class="{true?'active':'name'}">写法一</div>
<div :class="['name', flag == true?'active':'']">写法二</div>