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. java——Byte類/包裝類的使用說明2. android studio實現(xiàn)簡單的計算器(無bug)3. python 讀txt文件,按‘,’分割每行數(shù)據(jù)操作4. python Selenium 庫的使用技巧5. android 控件同時監(jiān)聽單擊和雙擊實例6. python+pywinauto+lackey實現(xiàn)PC端exe自動化的示例代碼7. vue使用exif獲取圖片經(jīng)緯度的示例代碼8. python logging.info在終端沒輸出的解決9. 詳解android adb常見用法10. Python 忽略文件名編碼的方法
