Import Vue From Vue

Posted on  by admin
Modified1 year, 5 months ago.

I'm going crazy trying to reconcile the Vue 3 CLI output into something that works with various tutorials and plugins that all use the Vue object, as in Vue.createApp(..

In my project, I can use. but import Vue from 'vue'; results in Vue still being undefined. I have Vue 3 installed via NPM. Clearly there is something critical that I don't understand about NPM imports, how could the {createApp} import work if importing the whole module does not work?


Here is my temporary main.js. This prints 'undefined' followed by the correct createApp function definition:.

128128 bronze badges. 47911 gold badge55 silver badges1313 bronze badges. 55 silver badges1313 bronze badges. If you're working with CDN Vue is available as global variable which could be used to create instance by calling the method createApp like Vue.createApp({..}), but if you're working with a bundler which uses npm modules, there no Vue object imported from vue module so you should import createApp from it to create a new instance like :.

for more details please check the migration guide of global API. 1414 gold badges103103 silver badges128128 bronze badges.

128128 bronze badges. You’re browsing the documentation for v2.x and earlier. For v3.x, click here. This page assumes you’ve already read the Components Basics. Read that first if you are new to components.

When registering a component, it will always be given a name. For example, in the global registration we’ve seen so far:. The component’s name is the first argument of Vue.component.


Not the answer you're looking for? Browse other questions tagged vue.jsvuejs2vue-component or ask your own question.