vue父子组件间调用方法

2021-05-25  本文已影响0人  lvyweb

标签(空格分隔): vue


父组件调用子组件方法

子组件中

  this.$emit('nodeClick', obj);

父组件中

 <report-real class="zero-real" ref="reportReal" @nodeClick='showSecond'></report-real>
 //主要看nodeClick   showSecond 是父组件的方法

子组件调用父组件方法

子组件

 this.$parent.fatherMethod();

父组件

  methods: {
      fatherMethod() {
        console.log('测试');
      }
  };
上一篇 下一篇

猜你喜欢

热点阅读