[Vuejs]-Calling Vue3 component methods from outside

1👍

This question was answered by Estus Flask in the comments section.

app.js

import { createApp } from "vue";
import App from "./app.vue";

let app = createApp(App)
let vm = app.mount("#app"); //This return instance is the proxy to the VueJs component

window.vm = vm;

2👍

In Vue 3, to access the internal methods of a component, you should consider using defineExpose to expose the method in that component

https://vuejs.org/api/sfc-script-setup.html#defineexpose

👤KitKit

Leave a comment