|
| - | ---------------------------------------------------------------------- | | | | | | | | | | | | | | | | | | Document | | | | | | | | |
|
| | |
| |
|
| | |
| | , |
| | data(){ |
| | return { |
| | msg: '这是子组件数据' |
| | } |
| | }, |
| | methods: { |
| | emit(){ |
| | // 触发子组件的自定义事件 |
| | // emit('biubiubiu', this.msg); |
| | } |
| | } |
| | } |
| | // 页面 |
| | const Home = { |
| | template: | | | <div> | | | 这是home页 | | | {{ msg }} | | | <hr/> | | | <common-head @biubiubiu="fn"></common-head> | | | </div> | | |, |
| | data(){ |
| | return { |
| | msg:"" |
| | } |
| | }, |
| | methods: { |
| | fn(msg){ |
| | console.log('我收到了', msg); |
| | this.msg = msg; |
| | } |
| | }, |
| | components: { |
| | CommonHead |
| | } |
| | } |
| | |
| | Vue.component('HomePage', Home) |
| | const vm = new Vue({ |
| | el: '#app' |
| | }) |
| | |
| | |
| |