Vue:$父母的父母

时间:2017-07-20 16:23:03

标签: vuejs2

我有一个子组件需要向父母的父母(祖父母?)说些什么。现在,这仅在父母充当管道时才有效:

从子组件

,我打电话给this.$emit('hello', 'hi grandma!')。然后父母从sayHello方法做同样的事情,然后祖父母最终收到数据:

<grandparent>
  <parent @hello="sayHello">
    <child></child>
  </parent>
</grandparent>

有没有更好的方式来沟通链?它看起来像docs recommend an event hub;这对我来说是一个更复杂的解决方案吗?

我有什么理由不能使用this.$parent.$emit('hello', 'hi grandma!')吗?

0 个答案:

没有答案
相关问题