0๐
โ
- Define data for each value
data() {
return {
...
oc_id: '',
sub_id: '',
}
}
- Bind datas to inputs using
v-model
<select v-model="oc_id" multiple class="form-control">
<option v-for="(oclist , index) in oclists" :key="oclist.id" :value="oclist.id">{{ oclist.name }}</option>
</select>
...
<select v-model="sub_id" multiple class="form-control" v-if="sublists.length>0">
<option v-for="(sublist , index) in sublists" :key="sublist.id" :value="sublist.id">{{ sublist.name }}</option>
</select>
- Use data everywhere you want
addMatch() {
axios.post("/ocs", {
oc_id: this.oc_id,
sub_id: this.sub_id
})
...
}
Source:stackexchange.com