<template>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
prop="date"
label="日期"
width="180">
<template #default="{row,$index}">
<input type="text" v-model="row.date" v-show="row.display" />
<span v-show="!row.display">{{row.date}}</span>
</template>
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">
</el-table-column>
<el-table-column label="操作" width="180">
<template #default="{row,$index}">
<el-button type="warning" @click="edit(row)">编辑</el-button>
<el-button type="danger" @click="save(row)">保存</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎'
}, {
date: '2016-05-04',
name: '王小虎'
}]
}
},
methods: {
edit(row, index) {
row.display = true;
},
save(row, index) {
row.display = false;
}
}
}
</script>
【vue3】可编辑el-table
陈晓明start2023-10-10 11:21
相关推荐
仿生狮子1 小时前
把 Git 提交历史变成一条流动的河——Project RiverLCG元4 小时前
STM32实战:基于STM32F103的Bootloader设计与IAP在线升级xixingzhe25 小时前
idea启动vue项目前端一小卒6 小时前
前端工程师的全栈焦虑,我用 60 天治好了coderyi7 小时前
LLM Agent 浅析我叫黑大帅7 小时前
TypeScript 6.0 弃用选项错误 TS5101 解决方法科雷软件测试7 小时前
使用python+Midscene.js AI驱动打造企业级WEB自动化解决方案We་ct8 小时前
LeetCode 120. 三角形最小路径和:动态规划详解|晴 天|9 小时前
Vue 3 + LocalStorage 实现博客游戏化系统:成就墙、每日签到、积分商城changshuaihua00110 小时前
React 入门