Vue父子组建之间进行方法调用

一、父组件调用子组件函数

父组件:

<template>
    <child ref="editFun"></child> //子组件绑定
</template>

父组件调用子组件函数

this.$refs.editFun.init(参数);

子组件:

methods:{
  init(参数){
  //父组件调用子组件的方法 } }

二、子组件调用父组件函数

子组件

export default{
     props:{
        refreshList:{
            type:Function,
            default:null
     } } }

子组件调用父组件函数

this.refreshList(参数);

扫描二维码关注公众号,回复: 10222048 查看本文章

父组件:

<template>

<child :refreshList="initDom"></child>     //子组件绑定

</template>

methods:{
    initDom(参数){}
}

猜你喜欢

转载自www.cnblogs.com/wangbin96/p/12582213.html