作用
子组件改变父组件的值,然后再传给子组件。
下面的示例中,当子组件调用了$emit
方法,会将父组件的test
改变,并传递给子组件。
示例
父组件
<child :snycTest.sync="test"></child>
data () {
return {
test: 'hi'
}
},
子组件
props:['snycTest'],
methods: {
changeFather () {
this.$emit('update:snycTest', 'hello')
}
}