vue 父組件調用子組件的方法

vue 父組件調用子組件的方法

父組件:html

html:
<component-name ref="componentref"></component-name> //子組件名稱 js:
this.$refs.componentref.show();//在你須要的地方,調用便可

子組件:vue

methods:{
        show(){
            console.log('我是子組件方法,你調用到我了哦');
        }
    }
相關文章
相關標籤/搜索