Refactor betterPricesMap updates in RevenueSection for Vue 3 reactivity
- Updated the handling of betterPricesMap to create a new object for state updates, ensuring reactivity in Vue 3. - This change replaces direct assignments with spread operator syntax to maintain the integrity of the reactive system. - Aims to improve performance and align with Vue 3 best practices for state management.
This commit is contained in:
@@ -131,11 +131,17 @@
|
||||
}
|
||||
});
|
||||
// Speichere betterPrices in einem separaten Map, nicht auf dem product Objekt
|
||||
// In Vue 3 ist $set nicht mehr nötig, direkte Zuweisung funktioniert
|
||||
this.betterPricesMap[product.id] = data || [];
|
||||
// In Vue 3 müssen wir ein neues Objekt erstellen, um die Reaktivität zu triggern
|
||||
this.betterPricesMap = {
|
||||
...this.betterPricesMap,
|
||||
[product.id]: data || []
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`Error loading prices for product ${product.id}:`, error);
|
||||
this.betterPricesMap[product.id] = [];
|
||||
this.betterPricesMap = {
|
||||
...this.betterPricesMap,
|
||||
[product.id]: []
|
||||
};
|
||||
} finally {
|
||||
this.loadingPrices.delete(product.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user