P粉0578693482023-08-27 09:34:46
The problem is that you are trying to change a prop and the corresponding vuex state outside of the mutation. Passing a value to the v-model
directive will create a two-way data binding. Your task
prop refers to an object in the state. When q-checkbox
changes the value of task.completed
, the object is updated directly in the state. Instead, you should create a mutation that updates your task:
export const mutations = { updateTask(state, payload){ const task = state.tasks.find(t => t.id === payload.id); if(task) Object.assign(task, payload) } }
Then you can use this mutation
in the template<q-checkbox :value="task.completed" @input="updateTask({id: task.id, completed: !task.completed})" />
Also note that the actual prop and event names of the q-checkbox
component may vary depending on how you implement it