修复Collection对象set数据时,对象中的数组值未更新的问题

This commit is contained in:
dgflash
2023-06-29 10:15:03 +08:00
parent a9d21845e2
commit 794d140737

View File

@@ -20,7 +20,12 @@ export class Collection<K, V> extends Map<K, V>{
* @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);
}