How to access external Vue3 instance to call functions?
P粉141911244
2023-09-02 14:36:10
<p>How do I access a Vue 3 instance if I don't know the name of the variable that stores the instance? I need to call a function from a specific component. </p>
<p>When typing <code>$0.__vue_app__</code> in the console (Chrome Developer Tools), I see the instance's data, but how do I use it in code inside the JS file? </p>
<p><code>console.log($0)</code> is of course undefined. </p>
<p>Which way can I take to get here? </p>
One option is in workerCode>mounted()such as:
In
myWorker.js
you can do this: