From 55381985565b16136ef8e2ca9bcadae75acd4b03 Mon Sep 17 00:00:00 2001 From: gd4ark Date: Thu, 4 Jun 2020 11:25:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(edit-table):=20oldValue=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #61 --- examples/docs/zh-CN/edit-table.md | 28 +++++++++++++--------------- packages/edit-table/src/main.vue | 3 ++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/docs/zh-CN/edit-table.md b/examples/docs/zh-CN/edit-table.md index 2c4b5eaa473..0f236ceaf5d 100644 --- a/examples/docs/zh-CN/edit-table.md +++ b/examples/docs/zh-CN/edit-table.md @@ -516,7 +516,7 @@ export default { :::demo ```html -异步更新 +Append SetOptions @@ -524,7 +524,13 @@ export default { export default { data() { return { - data: [], + id: 1, + data: [ + { + id: `第 1 行`, + option: '', + }, + ], columns: [ { id: 'id', @@ -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) => { diff --git a/packages/edit-table/src/main.vue b/packages/edit-table/src/main.vue index 0c06f42d26d..df1a9329620 100644 --- a/packages/edit-table/src/main.vue +++ b/packages/edit-table/src/main.vue @@ -171,6 +171,8 @@ export default { value(v) { this.resetRowOptionsData(v, this.oldValue); + this.oldValue = [...v]; + this.indexKeys = v.map((_, i) => i); } }, @@ -207,7 +209,6 @@ export default { }, updateValue(value) { - this.oldValue = [...this.model.data]; this.$emit('input', value); },