vue 父組件調用子組件

1、在父組件裏引用自組件
<generate-report @closeAddReport="closeAddReport" ref="addreport"></generate-report>

2、在子組件中寫對應的方法

methods: {
    childMethods() {
        alert(12)
      },
}

3、在父組件中調用

this.$refs.addreport.childMethods();

 

重點:這裏有個重點,ref等號後面的值不能駝峯命名

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章