<template>
<div>
<v-header ref='header'></v-header>
<v-content ref='content'></v-content>
<v-footer ref='footer'></v-footer>
<button @click='emitChild1'>ref与on触发</button>
<button @click='emitChild2'>ref直接触发</button>
<button @click='emitChild3'>children与on触发</button>
<button @click='emitChild4'>children直接触发</button>
</div>
</template>
<script>
import vHeader from './Header';
import vContent from './Content';
import vFooter from './Footer';
export default {
components:{vHeader,vContent,vFooter},
methods:{
emitChild1(){
this.$refs.footer.$emit('bridge','你好吗!');
this.$refs.footer.$emit('bridge');
},
emitChild2(){
this.$refs.footer.childAction('你好吗!');
this.$refs.footer.childAction();
},
emitChild3(){
this.$children[2].$emit('bridge','你好吗!');
this.$children[2].$emit('bridge');
},
emitChild4(){
this.$children[2].childAction('你好吗!');
this.$children[2].childAction();
},
}
}
</script>