As shown below:
<template> <el-table :data="tableData" border @cell-mouse-enter="handleMouseEnter" @cell-mouse-leave="handleMouseOut" style="width: 100%"> <el-table-column label="date" width="180"> <template scope="scope"> <span v-if="!">{{ }}</span> <span v-if="" class="cell-edit-input"><el-input v-model="inputColumn1" placeholder="Please enter content"></el-input></span> <span v-if="!" style="margin-left:10px;" class="cell-icon" @click="handleEdit()"> <i class="el-icon-edit"></i> </span> <span v-if="" style="margin-left:10px;" class="cell-icon" @click="handleSave()"> <i class="el-icon-document"></i> </span> </template> </el-table-column> </el-table> </template> <script> export default{ data(){ return { tableData:[ { name:"test", editeFlage:false }, { name:"test", editeFlage:false }, { name:"test", editeFlage:false }, { name:"test", editeFlage:false }, ], inputColumn1:""//The input box of the first column } }, methods:{ handleEdit:function(row){ //Transfer the array to change editFlag }, handleSave:function(row){ //Save data and fetch data from the background }, handleMouseEnter:function(row, column, cell, event){ [0].children[1].="black"; }, handleMouseOut:function(row, column, cell, event){ [0].children[1].="#ffffff"; } } } </script> <style> .cell-edit-input .el-input, .el-input__inner { width:100px; } .cell-icon{ cursor:pointer; color:#fff; } </style>
The above example of the element-ui table that makes cells editable is all the content I share with you. I hope you can give you a reference and I hope you can support me more.