I have a store that contains states, changes, getters, etc. The status contains the following list of tasks.
const state = { tasks:[{ title: "Get up", completed: false }, { title: "Project 2", completed: false }, ] }
Todo.vue
task.vue
//////////////// The problem lies in this line {{task.name}}
In the above code, in Task.vue
The problem is in this line. If I remove v-model="task.completed"
from the code given above then everything works fine otherwise it throws an error with the message Unexpected mutation of "task" prop
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. Yourtask
prop refers to an object in the state. Whenq-checkbox
changes the value oftask.completed
, the object is updated directly in the state. Instead, you should create a mutation that updates your task:Then you can use this mutation
in the templateAlso note that the actual prop and event names of the
q-checkbox
component may vary depending on how you implement it