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

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

父组件:html

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

子组件:vue

methods:{
        show(){
            console.log('我是子组件方法,你调用到我了哦');
        }
    }
相关文章
相关标签/搜索