vue3点击表格某个单元格文本就切换成输入框,其他单元格不变化

html 复制代码
<el-table :data="data.tableData" height="60vh" border scrollbar-aways-on>
        <el-table-column label="序号" type="index" width="80" fixed />
        <el-table-column label="操作" width="120" fixed>
            <template #default="{ row }">
                <el-button type="danger" text @click="deleteBtn(row)" :disabled="row.status">删除</el-button>
                <el-button style="color: #3592FF" text @click="enableBtn(row)">{{ row.status ? '停用' : '启用' }}</el-button>
            </template>
        </el-table-column>
        <el-table-column prop="status" label="状态" width="120" />
        <el-table-column prop="phone" label="手机号" />
        <el-table-column prop="kanno" label="操作人" />
        <el-table-column prop="kanno" label="操作时间" />
        <el-table-column prop="kanno" label="创建人" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column label="姓名">
            <template #default="scope">
                <template v-if="scope.cellIndex == cellIndex && scope.$index == index">
                    <el-input v-model="scope.row.status" @blur="saveCell" />
                </template>
                <template v-else>
                    <div @click="editCell(scope, scope.$index)">{{ scope.row.status }}</div>
                </template>
            </template>
        </el-table-column>
    </el-table>
javascript 复制代码
const cellIndex = ref('')
const index = ref('')

function editCell(row, ind) {
    cellIndex.value = row.cellIndex
    index.value = ind
}
function saveCell() {
    cellIndex.value = ''
    index.value = ''
}

效果如下

点击第一行的文本

点击第二行文本

相关推荐
BBBBBAAAAAi5 小时前
Claude Code安装记录
开发语言·前端·javascript
源码获取_wx:Fegn08956 小时前
基于 vue智慧养老院系统
开发语言·前端·javascript·vue.js·spring boot·后端·课程设计
毕设十刻6 小时前
基于Vue的人事管理系统67zzz(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js
QQ19632884756 小时前
ssm基于Springboot+的球鞋销售商城网站vue
vue.js·spring boot·后端
Jing_Rainbow6 小时前
【 前端三剑客-37 /Lesson61(2025-12-09)】JavaScript 内存机制与执行原理详解🧠
前端·javascript·程序员
UIUV7 小时前
模块化CSS学习笔记:从作用域问题到实战解决方案
前端·javascript·react.js
aoi7 小时前
解决 Vue 2 大数据量表单首次交互卡顿 10s 的性能问题
前端·vue.js
Kakarotto7 小时前
使用ThreeJS绘制东方明珠塔模型
前端·javascript·vue.js
幽络源小助理7 小时前
springboot校园车辆管理系统源码 – SpringBoot+Vue项目免费下载 | 幽络源
vue.js·spring boot·后端
donecoding7 小时前
TypeScript `satisfies` 的核心价值:两个例子讲清楚
前端·javascript