Javascript 如何使用Vue中的受控组件设置父组件对象中的值

Javascript 如何使用Vue中的受控组件设置父组件对象中的值,javascript,vue.js,vue-component,Javascript,Vue.js,Vue Component,我知道如何使用受控组件来发出选定的值。比如说, // app-select.vue <v-select :items="[1,2,3]" @change="$emit('input', $event)"></v-select> // parent-component.vue <app-select v-model="selectedValue" /> 以及一个具有多个输入的孩子,能够在输入时

我知道如何使用受控组件来发出选定的值。比如说,

// app-select.vue

<v-select :items="[1,2,3]"  @change="$emit('input', $event)"></v-select>

// parent-component.vue

<app-select v-model="selectedValue" />
以及一个具有多个输入的孩子,能够在输入时发出:

<template>
   <v-select :items="filterOneItems" @change="$emit('input', $event)">></v-select>
   <v-select :items="filterTwoItems" @change="$emit('input', $event)">></v-select>
</template>

有什么办法可以让它发挥作用吗?

我可以想出两种解决方案。第一种解决方案,只需使用道具而不是双向绑定:

对于母公司vue


对于
过滤器组件vue


。。。
道具:{
obj:{
类型:对象,
默认值:{}
}
}
...

第二种解决方案,如您所述使用
v-model

对于
过滤器组件vue


。。。
方法:{
更改(名称、值){
此.$emit('input'{
…这个值,
[名称]:值
})
}
}
...

<template>
   <v-select :items="filterOneItems" @change="$emit('input', $event)">></v-select>
   <v-select :items="filterTwoItems" @change="$emit('input', $event)">></v-select>
</template>
filterObj: {
   filterOne: 'value 1',
   filterTwo: 'value 2'
}