From 441024b99361c7e9895f22b0388f403af75ee8b4 Mon Sep 17 00:00:00 2001 From: Jeminas <86997663+JeminasJ@users.noreply.github.com> Date: Tue, 11 Jan 2022 16:14:31 +0800 Subject: [PATCH] docs:table demo optimize (#5142) --- antdv-demo/docs/table/demo/edit-row.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/antdv-demo/docs/table/demo/edit-row.md b/antdv-demo/docs/table/demo/edit-row.md index ec55649aa..0f4ade792 100644 --- a/antdv-demo/docs/table/demo/edit-row.md +++ b/antdv-demo/docs/table/demo/edit-row.md @@ -91,7 +91,7 @@ export default { methods: { handleChange(value, key, column) { const newData = [...this.data]; - const target = newData.filter(item => key === item.key)[0]; + const target = newData.find(item => key === item.key); if (target) { target[column] = value; this.data = newData; @@ -99,7 +99,7 @@ export default { }, edit(key) { const newData = [...this.data]; - const target = newData.filter(item => key === item.key)[0]; + const target = newData.find(item => key === item.key); this.editingKey = key; if (target) { target.editable = true; @@ -109,8 +109,8 @@ export default { save(key) { const newData = [...this.data]; const newCacheData = [...this.cacheData]; - const target = newData.filter(item => key === item.key)[0]; - const targetCache = newCacheData.filter(item => key === item.key)[0]; + const target = newData.find(item => key === item.key); + const targetCache = newCacheData.find(item => key === item.key); if (target && targetCache) { delete target.editable; this.data = newData; @@ -121,10 +121,10 @@ export default { }, cancel(key) { const newData = [...this.data]; - const target = newData.filter(item => key === item.key)[0]; + const target = newData.find(item => key === item.key); this.editingKey = ''; if (target) { - Object.assign(target, this.cacheData.filter(item => key === item.key)[0]); + Object.assign(target, this.cacheData.find(item => key === item.key)); delete target.editable; this.data = newData; }