组件通信-ref链传输数据

(通过ref链 实现子传父—>父传子)

	
_____________________________________________________________________________ Vue.component('Father', { template: '#father', (5.将数据传给父组件) data() { return { n: 0 } }, (6.父组件保存数据的值) methods: { transport() { this.n = this.$refs.msgaa.content } } }) Vue.component('Msga', { template: '#msga', (2.数据传输) data(){ return{ content:数据 } } }) Vue.component('Msgb', { template: '#msgb', (3.数据接收) data(){ return{ num:0 } }, (9.定义接收数据) methods:{ output(){ console.log(this.$attrs.abc) } } }) new Vue({ el: '#app' })

你可能感兴趣的:(组件通信-ref链传输数据)