el-table點擊某一行高亮並顯示小圓點的實現代碼
<el-table height="93%" :header-cell-style="{background:'#E5EBF1',color:'#517085'}" :data="tableData1" tooltip-effect="dark" @row-click="clickDetailsFun" :row-class-name="tableRowClassName" :row-style="selectedRowStyle" highlight-current-row //高亮設置 style="width: 100%"> <el-table-column width="30"> <template slot-scope="scope"> <div :id="scope.$index"></div> </template> </el-table-column> <el-table-column prop="name" label="電壓范圍"> </el-table-column> <el-table-column prop="value" label="個數"> </el-table-column> </el-table>
js部分
tableRowClassName({ row, rowIndex }) { row.rowIndex = rowIndex; }, selectedRowStyle({ row, rowIndex }) { //關鍵代碼 if (this.getRowIndex === rowIndex) { document.getElementById(rowIndex).className = "dis" }else{ if(document.getElementById(rowIndex)){ document.getElementById(rowIndex).className = "dis2" } } }, clickDetailsFun(val){ this.getRowIndex = val.rowIndex; }
css
//高亮 /deep/.el-table__body tr.current-row>td{ background-color: #d7f3e4 !important; } //圓點樣式 .dis{ border-radius: 100px; width:10px; height:10px; background:#39C178; } .dis2{ display: none; }
效果
到此這篇關於el-table點擊某一行高亮並顯示小圓點的文章就介紹到這瞭,更多相關el-table點擊高亮顯示小圓點內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!
推薦閱讀:
- vue+el-table實現合並單元格
- vue+elementUI實現內嵌table的方法示例
- 關於el-table表格組件中插槽scope.row的使用方式
- vue中的slot-scope及scope.row用法
- 圖文詳解Element-UI中自定義修改el-table樣式