Skip to content

Commit

Permalink
fix(edit-table): oldValue 更新问题 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
gd4Ark authored Aug 10, 2020
1 parent e8f4124 commit af8b9aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
28 changes: 13 additions & 15 deletions examples/docs/zh-CN/edit-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,21 @@ export default {
:::demo

```html
<el-button @click="onSyncUpdate">异步更新</el-button>
<el-button @click="onSyncUpdate">Append</el-button>
<el-button @click="onSetOptions">SetOptions</el-button>
<el-edit-table ref="form" :columns="columns" v-model="data"></el-edit-table>

<script>
export default {
data() {
return {
data: [],
id: 1,
data: [
{
id: `第 1 行`,
option: '',
},
],
columns: [
{
id: 'id',
Expand All @@ -549,20 +555,12 @@ export default {
},
methods: {
onSyncUpdate() {
this.data = [
{
id: '第 1 行',
for (let i = 0; i < 3; i++) {
this.data.push({
id: `${++this.id}`,
option: '',
},
{
id: '第 2 行',
option: '',
},
{
id: '第 3 行',
option: '',
},
]
})
}
},
onSetOptions() {
this.data.forEach((e, i) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-table/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ export default {
value(v) {
this.resetRowOptionsData(v, this.oldValue);
this.oldValue = [...v];
this.indexKeys = v.map((_, i) => i);
}
},
Expand Down Expand Up @@ -207,7 +209,6 @@ export default {
},
updateValue(value) {
this.oldValue = [...this.model.data];
this.$emit('input', value);
},
Expand Down

0 comments on commit af8b9aa

Please sign in to comment.