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 = ''
}

效果如下

点击第一行的文本

点击第二行文本

相关推荐
rfidunion7 小时前
springboot+VUE+部署(12。Nginx和前端配置遇到的问题)
前端·vue.js·spring boot
vx-Biye_Design7 小时前
servlet家政公司管理系统-计算机毕业设计源码01438
java·vue.js·spring·servlet·tomcat·maven·mybatis
FYKJ_20107 小时前
springboot大学校园论坛管理系统--附源码42669
java·javascript·spring boot·python·spark·django·php
Highcharts.js11 小时前
数据之美:用Highcharts打造专业级弧线图
javascript·数据库·highcharts·图表开发·弧线图
SuperEugene11 小时前
错误处理与 try/catch:真实项目里应该捕什么错?
前端·javascript·面试
夕除13 小时前
js--22
前端·javascript·python
Qhappy14 小时前
某加密企业版过frida检测
javascript
用户5798547697114 小时前
02:Agent Loop 深度剖析:ReAct 循环的工程实现
vue.js
用户57573033462414 小时前
🔥 一文搞懂 JavaScript 包装类(面试必考)
javascript
滕青山14 小时前
Base64编码/解码 核心JS实现
前端·javascript·vue.js