Answer the question
In order to leave comments, you need to log in
How to solve the problem with props mutation in a component?
I get the value prop into the component, then it changes (when editing the input, for example), I solved this problem through computed, everything works correctly, but how can I do it so as not to write the set section? Nothing happens in it and it is not needed, but if you delete it, then Vue swears at the lack of a setter:
selectedValue: {
get: function () {
return this.value;
},
set: function () {}
}
Answer the question
In order to leave comments, you need to log in
Rename value to initialValue (this means that the name reflects the essence more accurately), make selectedValue a normal property from the calculated property:
data() {
return {
selectedValue: this.initialValue,
};
},
set(val) {
this.$emit('input', val);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question