Sometimes, we want to fix the ‘Computed property "name" was assigned to but it has no setter’ error in Vue.js.
In this article, we’ll look at how to fix the ‘Computed property "name" was assigned to but it has no setter’ error in Vue.js.
How to fix the ‘Computed property "name" was assigned to but it has no setter’ error in Vue.js?
To fix the ‘Computed property "name" was assigned to but it has no setter’ error in Vue.js, we should make sure we don’t assign a value to a computed property.
For instance, we shouldn’t write
this.name = response.data;
if name
is a computed property.
And we also shouldn’t use name
as the value of v-model
.
These 2 things would ensure that we don’t accidentally try to set a computed property to a new value that has no setter.
Conclusion
To fix the ‘Computed property "name" was assigned to but it has no setter’ error in Vue.js, we should make sure we don’t assign a value to a computed property.