vue iview 單擊table行變色 獲取行數據


用到兩個事件:

 

 

 代碼如下:

1 <Table :columns="columns" :data="tableData" @on-row-click="rowClick" :row-class-name="rowClassName" :loading="loading"></Table>
1 data () {
2     return {
3       selectRow: {}
4     }
5   }
 1 methods: {
 2     rowClick (row, index) {
 3       this.selectRow = row //獲取行數據
 4     },
 5     rowClassName (row, index) { 
 6       if (row.CBDM == this.selectRow.CBDM) { //隨便挑個唯一變量比較
 7         return 'aa' //自己的css類名  iview文檔table那塊有幾個現成的樣式,建議寫進公共樣式里 
 8       }
 9       return ''
10     }
11 }
1 // 不要添加scoped會導致樣式無效
2 <style lange='less'>
3 .aa {
4   color: rgb(250, 195, 100);
5 }
6 </style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM