From 794d1407373b1aba3bd3ee5c1de63e459d3f014b Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 29 Jun 2023 10:15:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCollection=E5=AF=B9=E8=B1=A1s?= =?UTF-8?q?et=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=95=B0=E7=BB=84=E5=80=BC=E6=9C=AA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/libs/collection/Collection.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/libs/collection/Collection.ts b/assets/libs/collection/Collection.ts index e3e3eea..6b767e0 100644 --- a/assets/libs/collection/Collection.ts +++ b/assets/libs/collection/Collection.ts @@ -20,7 +20,12 @@ export class Collection extends Map{ * @param value 数据值 */ set(key: K, value: V) { - if (!this.has(key)) { + if (this.has(key)) { + var old = this.get(key)!; + var index = this._array.indexOf(old); + this._array[index] = value; + } + else { this._array.push(value); }