vue 父组件调用子组件的方法

vue 父组件调用子组件的方法

父组件:

html:
<component-name ref="componentref"></component-name> //子组件名称 js:
this.$refs.componentref.show();//在你需要的地方,调用即可

子组件:

methods:{
        show(){
            console.log('我是子组件方法,你调用到我了哦');
        }
    }

 

posted @ 2017-10-17 17:53  斗破苍穹-毅力  阅读(3724)  评论(0编辑  收藏  举报