V
V
VctorIAN2021-06-08 04:48:46
Vue.js
VctorIAN, 2021-06-08 04:48:46

Is it possible to implement an event bus based on import, Vue 3 cli?

Hello, I have several pages with many components (different pages can have the same function names) can I make each page an event bus where each component can receive and emit an event to the page.
On Vue 2, I implemented this with

//main.js
global.context = new Object();
global.context.app = app;

and gave each page a field with an assigned context
//к примеру одна из страниц
 global.context.authorization = this;

//в каком либо компоненте страницы емиттил 
global.context.authorization.$emit(
          "authorizationMessage",
          this.t("Password fields didn't match")
        );
//и таким же образом онил

But since vue 3 relies heavily on imports, can I improve the approach to such event buses using imports...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question