[Vuejs]-How to comunicate two Vue.js applications

0👍

I discovered how to do this, I have to define the createApp app #1 as a public variable, then i can call to its methods, firstly I change this:

<app>
</app>
<script>
let app1;
(function() {
        const app_rid = rid()
        $("app").last().attr("id", app_rid)
        app1 = createApp({
                methods: {
                        Example() {
                        }
                }
        }).mount("#"+app_rid)
});
</script>

Then I can call to it’s methods like this:

app1.Example();

Also I saw that I could refactor the app id definition with this simpler code:

$("app").last().attr("id", rid())
createApp({}).mount("#"+$("app").last().attr("id"))

That way It’s not needed to define them on anonymous functions.

Leave a comment