Article From:

Why is this event monitoring placed in created?
And why use

Answer 0:

This is supposed to be two brothers components communicating through event bus.

window.eventsThe Vue object is stored. = new Vue();

$onIt is used to register an event, so it is placed in created, and $emit triggers the event. You can refer to the Vue event mechanism.

Answer 1:

He should have built an empty Vue instance to do eventbus and put this instance on the window object.
eg: = new Vue();$on(...)

Leave a Reply

Your email address will not be published. Required fields are marked *