Vue · Middle · Question 40 of 75
What does store.$patch offer?
cart.$patch((state) => {
state.items.push(item);
state.updatedAt = Date.now();
});- ✓Correct answer: Applies several changes as one grouped mutation, shown as a single entry in devtools
- 2Sends the changes to the server
- 3Reverts the store to its initial state
Explanation
$patch takes a partial object or a function. Direct assignments (cart.total = 0) also work; $patch is useful for batching and readability.