Vue.js, what's the difference between $ emit and $ dispatch?

In vue2.0 event $dispatchand $broadcastdate.

And I found that $dispatchlook like $emit.

What are the differences between the two? Is it safe to directly replace $dispatchwith $emitduring transfer?

+4
source share
1 answer

No, you can not replace $disptachon $emiteverywhere. You can replace it wherever you use it to communicate from child to parent , but for other cases you may need a different approach.

( Evan ):

. $emit v-on. .

/ $emit . .

$dispatch

, , . , , true.

$emit:

. .

, , , $dispatch, - $emit

+9

Source: https://habr.com/ru/post/1662592/


All Articles