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; }