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.
My code:
const app = Vue.createApp({
data() {
return {
data: ["this","is","an", "example"],
}
},
methods: {
getData() {
return this.data;
},
},
});
app.mount('#app');
// This instruction fails!
console.log(app.getData());
When I am trying to execute the method on the last line, i get in the console:
Uncaught TypeError: Cannot read property 'content' of undefined
Why I can not execute the method? what is wrong?