<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
相关推荐
一点 内容3 分钟前
深入浅出:解锁React Hooks的魔法——从入门到实战优化指南紫_龙5 分钟前
最新版vue3+TypeScript开发入门到实战教程之组件通信之一故以往之不谏7 分钟前
JAVA--类和对象4.1--构造方法基础yivifu10 分钟前
接近完美的HTML文本双行合一排版fxshy11 分钟前
前端直连模型 vs 完整 MCP:大模型驱动地图的原理与实践(技术栈Vue + Cesium + Node.js + WebSocket + MCP)destinying17 分钟前
性能优化之项目实战:从构建到部署的完整优化方案吃不胖爹17 分钟前
flutter项目如何打包,创建签名与配置签名英俊潇洒美少年18 分钟前
react如何实现双向绑定我命由我1234520 分钟前
React - React Redux 数据共享、Redux DevTools、React Redux 最终优化英俊潇洒美少年20 分钟前
数据驱动视图 vue和react对比