javascript - vue 元素加樣式該怎么做
問題描述
主要問題是: 之前記得能$index傳遞一個index然后就好辦了, 怎么知道當前tr渲染是的是第幾行數據, 如何用computed做
我想改變文字顏色
我的代碼: 

問題解答
回答1:寫好樣式,然后動態綁定 :class ='{green:true,red:false.....}'
回答2:你用的是element-ui框架吧,在el-table里有這么一個屬性row-class-name,是一個回調函數,可以給table-cell加class。詳情你可以看一下官網,在最下面。舉個栗子:(通過判斷一行數據中的值來顯示不同的背景顏色)template
<el-table :data='roleMenuTable' border :row-class-name='tableRowClassName'>
script
methods: { // 已選擇渲染樣式 tableRowClassName (row, index) { if (row.operation) {return ’info-row’ } else {return ’’ } } }
style
<style>.el-table .info-row{ background: #5CB85C;}</style>
效果:
現在也可以啊,把v-for改成v-for='(item, index) in lists',inde就是索引了
相關文章:
1. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””2. boot2docker無法啟動3. docker-compose中volumes的問題4. nignx - docker內nginx 80端口被占用5. docker安裝后出現Cannot connect to the Docker daemon.6. java - SSH框架中寫分頁時service層中不能注入分頁類7. dockerfile - 為什么docker容器啟動不了?8. 關于docker下的nginx壓力測試9. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值10. docker容器呢SSH為什么連不通呢?

網公網安備