您的位置:首页 > 教育 > 锐评 > 怎么搭建论坛_网址大全汽车之家官方网_世界足球排名前十名_做互联网项目怎么推广

怎么搭建论坛_网址大全汽车之家官方网_世界足球排名前十名_做互联网项目怎么推广

2024/10/6 6:01:17 来源:https://blog.csdn.net/qq_48817343/article/details/142483118  浏览:    关键词:怎么搭建论坛_网址大全汽车之家官方网_世界足球排名前十名_做互联网项目怎么推广
怎么搭建论坛_网址大全汽车之家官方网_世界足球排名前十名_做互联网项目怎么推广

1、使用@cell-dblclick事件,当双击时触发事件

<el-table @cell-dblclick="handleCellDblClick"

2、单元格设置

主要重点为判断双击时切换input框,然后绑定ref,设置失去焦点时触发点方法,与按enter键触发点方法

<el-table-column prop="name" label="姓名" width="180"><template slot-scope="scope"><span v-if="editableData !== scope.row">{{ scope.row.name }}</span><el-inputv-else:ref="'input-' + scope.$index"v-model="scope.row.name"@blur="handleInputBlur(scope.row)"@keyup.enter.native="handleInputEnter(scope.row)"></el-input></template></el-table-column>

3、添加当前编辑的数据

editableData: null, // 当前编辑的数据项

4、为所有的方法赋予逻辑

// 双击时触发
handleCellDblClick(row, column, cell, event) {if (column.property === 'customerBoxNum') {this.editableData = row; // 设置当前编辑的数据项this.$nextTick(() => {const inputRef = 'input-' + this.boxList.indexOf(row);const inputElement = this.$refs[inputRef];if (inputElement) {inputElement.focus(); // 聚焦输入框} else {console.error('Input element not found:', inputRef);}});}
},
handleInputBlur(row) {// 输入框失去焦点时保存更改this.editableData = null; // 返回到静态显示状态
},
handleInputEnter(row) {// 按下回车键时保存更改this.editableData = null; // 返回到静态显示状态
},

5、打完收工

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com