vue element table 表头添加图标

1 1 <template> 2 2 <el-table 3 3 :data="tableData" 4 4 border 5 5 @cell-mouse-enter="handleMouseEnter" 6 6 @cell-mouse-leave="handleMouseOut" 7 7 style="width: 100%"> 8 8 <el-table-column 9 9 label="日期" 10 10 width="180" :render-header="renderHeader"> <!-- // 加入render事件 --> 11 11 <template slot-scope="scope"> 12 12 <span v-if="!scope.row.editeFlag">{{ scope.row.name }}</span> 13 13 <span v-if="scope.row.editeFlag" class="cell-edit-input"><el-input @blur="onblur(scope.$index,scope.row)" v-model="scope.row.name" placeholder="请输入内容"></el-input></span> 14 14 <span v-if="!scope.row.editeFlag" style="margin-left:10px;" class="cell-icon" @click="handleEdit(scope.$index,scope.row)"> <i class="el-icon-edit"></i> </span> 15 15 <span v-if="scope.row.editeFlag" style="margin-left:10px;" class="cell-icon" @click="handleSave(scope.$index,scope.row)"> <i class="el-icon-document"></i> </span> 16 16 </template> 17 17 </el-table-column> 18 18 <el-table-column 19 19 label="状态" 20 20 width="180"> <!-- // 加入render事件 --> 21 21 <template slot-scope="scope"> 22 22 <i v-if="scope.row.editeFlag==1" style="color:blue" class="el-icon-caret-right"></i> 23 23 <i v-else class="el-icon-caret-right"></i> 24 24 <span>{{ scope.row.editeFlag==1?'启动':'禁用' }}</span> 25 25 </template> 26 26 </el-table-column> 27 27 </el-table> 28 28 29 29 30 30 </template> 31 31 32 32 <script> 33 33 import Vue from 'vue' 34 34 export default{ 35 35 36 36 37 37 data(){ 38 38 return { 39 39 tableData:[], 40 40 inputColumn1:""//第一列的输入框 41 41 } 42 42 }, 43 43 created(){ 44 44 for(var index=0;index<10;index++){ 45 45 this.tableData[index]={name:"test",editeFlag:0}; 46 46 } 47 47 this.tableData[0]={name:"test",editeFlag:1}; 48 48 }, 49 49 methods:{ 50 50 handleEdit:function(index,row){ 51 51 this.tableData[index].editeFlag=true; 52 52 Vue.set(this.tableData,index,this.tableData[index]); 53 53 }, 54 54 handleSave:function(index,row){ 55 55 //保存数据,向后台取数据 56 56 this.tableData[index].editeFlag=false; 57 57 }, 58 58 handleMouseEnter:function(row, column, cell, event){ 59 59 if(column.label=="日期"){ 60 60 cell.children[0].children[1].style.color="black"; 61 61 } 62 62 }, 63 63 handleMouseOut:function(row, column, cell, event){ 64 64 if(column.label=="日期"){ 65 65 cell.children[0].children[1].style.color="#ffffff"; 66 66 } 67 67 68 68 }, 69 69 //input失去焦点 70 70 onblur(index,row){ 71 71 this.tableData[index].editeFlag=false; 72 72 Vue.set(this.tableData,index,this.tableData[index]); 73 73 }, 74 74 // render 事件 75 75 renderHeader (h,{column}) { // h即为cerateElement的简写,具体可看vue官方文档 76 76 return h( 77 77 'div', 78 78 [ 79 79 h('span', column.label), 80 80 h('i', { 81 81 class:'el-icon-location', 82 82 style:'color:#409eff;margin-left:5px;' 83 83 }) 84 84 ], 85 85 ); 86 86 } 87 87 } 88 88 } 89 89 90 90 </script> 91 91 92 92 <style> 93 93 .cell-edit-input .el-input, .el-input__inner { 94 94 width:100px; 95 95 } 96 96 .cell-icon{ 97 97 cursor:pointer; 98 98 color:#fff; 99 99 } 100100 </style>

View Code

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )