1.html部分
<div id="test">
<my-component ref="childFunction"></my-component>
</div>
2.自定义组件
Vue.component('my-component',{
templata:`<button>你好!</button>`,
methods:{
child:function(){
alert('我是自定义组件中的函数')
}
}
});
3.new一个Vue
myVue=new Vue({
el:'#test',
methods:{
father:function(){
this.$refs.childFunction.child();
}
}
})