I am brand new to Vue and am trying to learn how to use it.
I think I am getting tripped up trying to mount a new Vue app.
Here is what I can get to work:
<script src="https://unpkg.com/vue"></script>
<script>
const vm = new Vue({})
</script>
from there I am able to mount it and use everything correctly.
However, this currently loads an older version of Vue (2.6.7)
I'd like to learn on the newest version (Vue 3) so I tried importing the package recommended by Vue docs:
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = new Vue({})
</script>
and I get the following error in console:
Uncaught TypeError: Vue is not a constructor
I also tried mimicking the syntax from Vue 3's docs.
<script src="https://unpkg.com/vue@next"></script>
<script>
const vm = new Vue.createApp({})
</script>
but it throws the same error:
Uncaught TypeError: Vue.createApp is not a constructor
Using a different CDN or a specific version ([email protected]) also gives me the same result.
What am I doing wrong?
createApp
is not an object it's a function that returns an instance of vue app, so it should be :
const vm = Vue.createApp({}) //remove the new
createApp
Returns an application instance which provides an application context. The entire component tree mounted by the application instance share the same contextconst app = Vue.createApp({})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With