title: How to call a custom Vue 3 method from outside vue app in JavaScript?
body: <p>I have a simple app written in Vue. What I want is just to call a method from Vue, a custom method, outside of the Vue.createApp() method.</p>
  <p>My code:</p>
  <pre><code>const app = Vue.createApp({
  data() {
      return {
          data: [&quot;this&quot;,&quot;is&quot;,&quot;an&quot;, &quot;example&quot;],
      }
   },
   methods: {
    getData() {
      return this.data;
    },
   },
  });
  
  
  app.mount('#app');
  
  // This instruction fails!
  console.log(app.getData());
  </code></pre>
  <p>When I am trying to execute the method on the last line, i get in the console:</p>
  <pre><code>Uncaught TypeError: Cannot read property 'content' of undefined
  </code></pre>
  <p>Why I can not execute the method? what is wrong?</p>