el-table点击高亮显示小圆点

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

el-table点击高亮显示小圆点

你猜我为啥秃头   2022-09-29 我要评论
<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;
}

效果

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们