解决办法,使用 $set 重新给 data 赋值,原因尚不清楚(神烦啊,这什么双向绑定啊)
<el-table :data="data" stripe border>
<el-table-column label="操作" width="200px">
<template slot-scope="scope">
<el-button @click="saveClick(scope.$index, scope.row)" v-if="scope.row.isEdit" type="text" size="small">保存</el-button>
<el-button @click="editClick(scope.$index, scope.row)" v-if="!scope.row.isEdit" type="text" size="small">编辑</el-button>
</template>
</el-table-column>
</el-table>
methods: {
saveClick (index, row) {
row.isEdit = false
this.$set(this.data,index,row)
},
editClick (index, row) {
row.isEdit = true
this.$set(this.data,index,row)
}
},
本文介绍了一种在Vue框架中实现表格单元格编辑和保存功能的方法,通过使用$set方法更新data属性,确保了数据的正确绑定和更新。文章详细展示了如何在表格中切换编辑与显示模式,并提供了具体的代码实现。

1054

被折叠的 条评论
为什么被折叠?



