Vue 樣式切換及三元判斷樣式關(guān)聯(lián)操作
假設(shè)有需求:
后臺(tái)返回狀態(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、若要使啟用為綠色,禁用為紅色,可使用三元表達(dá)式綁定樣式
<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; }
補(bǔ)充知識(shí):vue通過判斷寫樣式(v-bind)
如下所示:
v-bind:style='$index % 2 > 0?’background-color:#FFF;’:’background-color:#D4EAFA;’'
以上這篇Vue 樣式切換及三元判斷樣式關(guān)聯(lián)操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP常用日期格式化函數(shù) FormatDate()2. ASP.NET MVC使用異步Action的方法3. ASP.NET MVC通過勾選checkbox更改select的內(nèi)容4. XML入門的常見問題(一)5. PHP循環(huán)與分支知識(shí)點(diǎn)梳理6. JSP之表單提交get和post的區(qū)別詳解及實(shí)例7. XML入門的常見問題(二)8. ASP中if語(yǔ)句、select 、while循環(huán)的使用方法9. jsp文件下載功能實(shí)現(xiàn)代碼10. ASP動(dòng)態(tài)網(wǎng)頁(yè)制作技術(shù)經(jīng)驗(yàn)分享
