Vue 樣式切換及三元判斷樣式關(guān)聯(lián)操作
假設(shè)有需求:
后臺返回狀態(tài)1:啟用,0:禁用
1、若要使啟用為綠色,禁用不添加其他樣式
<el-table-column prop='statusName' label='狀態(tài)'> <template slot-scope='scope'> <div :class='{active:scope.row.status==1}'> {{ scope.row.statusName }} </div> </template> </el-table-column> .active{ color:green; }
1、若要使啟用為綠色,禁用為紅色,可使用三元表達式綁定樣式
<el-table-column prop='statusName' label='狀態(tài)'> <template slot-scope='scope'> <div :class='scope.row.status==1? ’active’:’native’'> {{ scope.row.statusName }} </div> </template> </el-table-column>.active{ color:green; } .native{ color:red; }
補充知識:vue通過判斷寫樣式(v-bind)
如下所示:
v-bind:style='$index % 2 > 0?’background-color:#FFF;’:’background-color:#D4EAFA;’'
以上這篇Vue 樣式切換及三元判斷樣式關(guān)聯(lián)操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. IntelliJ IDEA設(shè)置自動提示功能快捷鍵的方法2. 詳解idea中web.xml默認版本問題解決3. IntelliJ IDEA導入jar包的方法4. IntelliJ IDEA 2020最新激活碼(親測有效,可激活至 2089 年)5. IntelliJ IDEA 統(tǒng)一設(shè)置編碼為utf-8編碼的實現(xiàn)6. asp知識整理筆記4(問答模式)7. idea修改背景顏色樣式的方法8. jsp EL表達式詳解9. 解決ajax的delete、put方法接收不到參數(shù)的問題方法10. 使用Python爬取Json數(shù)據(jù)的示例代碼
