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通過(guò)判斷寫(xiě)樣式(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í)現(xiàn)加法驗(yàn)證碼2. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向3. 將properties文件的配置設(shè)置為整個(gè)Web應(yīng)用的全局變量實(shí)現(xiàn)方法4. asp(vbs)Rs.Open和Conn.Execute的詳解和區(qū)別及&H0001的說(shuō)明5. CSS hack用法案例詳解6. ASP.NET MVC遍歷驗(yàn)證ModelState的錯(cuò)誤信息7. asp中response.write("中文")或者js中文亂碼問(wèn)題8. PHP設(shè)計(jì)模式中工廠模式深入詳解9. jsp網(wǎng)頁(yè)實(shí)現(xiàn)貪吃蛇小游戲10. 用css截取字符的幾種方法詳解(css排版隱藏溢出文本)
