How to access Vue 3 methods from outside

Viewed 201

I have defined a method in my Vue component:

export default {
    methods:{
        myMethod() {
          console.log("clicked");
        },
    },
} 

I want to call myMethod from outside Vue, something like:

myComponent.myMethod();

P.S. I'm trying to archive this because in Mapbox I can only define a popup with raw html, and I want to call a Vue method within a popup.

const popup = new mapboxgl.Popup().setHTML('<button id="button" @click="myMethod">Click here!</button>)
0 Answers
Related