当我们需要一个自定义组件在VueTable2中发出事件时,我们必须使用:
this.$parent.$emit('myCustomEvent')
// instead of
this.$emit('myCustomEvent')This thread告诉了我们更多关于这方面的信息。
我过去常常在必须触发事件时运行this.$emit()。我想知道它们之间的主要区别是什么?
发布于 2017-07-17 20:40:37
this.$emit将事件调度到其父组件。
this.$parent为您提供了对父组件的引用。
正如您可能已经猜到的那样,this.$parent.$emit会让父进程将事件分派给它的父进程。
https://stackoverflow.com/questions/45144483
复制相似问题