I was working on a large-scale Vue.js application, and I have used broadcast
and dispatch
tons of places in my application. What's the best way to sit down and change all these? Or do I have some other way to deal with these breaking-changes?
答案 0 :(得分:2)
Both these methods now are merged in the $emit
method.
Unfortunately, replacing every instance of $broadcast
and
$dispatch
with $emit
will not work because the pattern
used to manage events the one of the 'event emitter' now.
In my opinion the quickest way to deal with this deprecation is to create a spurious Vue instance and use it as an event hub.
答案 1 :(得分:1)
我最近遇到了与你相同的问题,因为我使用了很多$ broadcast和$ dispatch。解决方案是:
干杯