调用其他组件里面的方法--随笔

 A组件:
 import editMenuDialog from "./editMenuList"
 components:{"my-editMenuDialog":editMenuDialog}
 <div v-show="addMenuListShow">
      <my-addMenuDialog ref="addDialogVisible"  @refaddMenuList="refaddMenuList"></my-addMenuDialog>
 </div>
data:{
  return{
  addMenuListShow : false
}
}
method:{
 custom(){
  this.addMenuListShow = true;
    this.$refs.addDialogVisible.search();
},
  refaddMenuList(){
      this.search(); //B组件调用search方法
}  
    
}
B组件:

search(){
this.addDialog = true; } addForm(){ this.$emit("refaddMenuList") //调用A组件里面的search方法 }

 

posted @ 2020-04-02 16:28  云霄紫潭  阅读(495)  评论(0编辑  收藏  举报