In Vue.js 2, I used to be able to do this call my initialize() method from outside my class like this:
<!DOCTYPE html>
<head>
<script src="https://unpkg.com/vue@next"></script>
<title>test</title>
</head>
<body>
<div id="app">
<div>{{message}}</div>
</div>
<script>
const app = Vue.createApp({
data() {
return {
message: 'initial value'
}
},
methods: {
initialize() {
this.message = 'changed value';
}
}
});
app.mount("#app");
app.initialize();
</script>
</body>
</html>
But the above code in Vue.js 3 gets the error:
Uncaught TypeError: app.initialize is not a function
How can I do this in Vue.js 3?