【问题标题】:Difference between this.$parent.$emit and this.$emitthis.$parent.$emit 和 this.$emit 之间的区别
【发布时间】:2017-12-22 00:07:51
【问题描述】:

当我们需要自定义组件在VueTable2 中发出事件时,我们必须使用:

this.$parent.$emit('myCustomEvent')

// instead of
this.$emit('myCustomEvent')

This thread 告诉我们更多关于这方面的信息。

当我不得不触发一个事件时,我曾经运行this.$emit()。我想知道他们两个之间的主要区别是什么?

【问题讨论】:

    标签: vue.js vuejs2 vue-component


    【解决方案1】:

    this.$emit 向其父组件分派一个事件。

    this.$parent 为您提供对父组件的引用。

    您可能已经猜到了,this.$parent.$emit 将使父级将事件分派给其父级。

    【讨论】:

    • 我现在明白了!非常感谢基拉!
    猜你喜欢
    • 2020-09-19
    • 2020-06-18
    • 2013-10-23
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2012-08-18
    • 1970-01-01
    相关资源
    最近更新 更多