Answer the question
In order to leave comments, you need to log in
What is the best way to pass data from components with many inputs to the parent?
As I'm doing now - a lot of repetitive code, that is, in each field you need to set : value and a method in @input, while this method will only pass the argument to the top. Here's a demo of how I've done it now.
<div>
<input :value="city" @input="cityUpd">
<input :value="salary" @input="salaryUpd">
<input :value="exp" @input="expUpd">
<input :value="jtype" @input="jtypeUpd">
<input :value="curr" @input="currUpd">
</div>
props: {
salary: String,
city: String,
exp: String,
jtype: String,
curr: String,
},
methods: {
cityUpd(new1) {
this.$emit('cityUpd', new1)
},
salaryUpd(new1) {
this.$emit('salaryUpd', new1)
},
expUpd(new1) {
this.$emit('expUpd', new1)
},
jtypeUpd(new1) {
this.$emit('jtypeUpd', new1)
},
currUpd(new1) {
this.$emit('currUpd', new1)
},
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question