Victor Motogna
Victor Motogna

Reputation: 830

Vue 3 createApp not defined in Chrome

When using Vue 3 and the new createApp Chrome does not recognize it. In my main.js I have:

import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')

I tested with a newly generated vue-cli app and it does not work.

The Chrome Vue devtools does not recognize any localhost app and typing Vue in the console inside a Vue app says this: Uncaught ReferenceError: Vue is not defined at <anonymous>:1:1

Upvotes: 3

Views: 7296

Answers (1)

Matt
Matt

Reputation: 10412

There are two ways to run a new Vue 3 project which has been created with the Vue CLI.

  1. Start the dev server by running npm run serve and open a browser to http://127.0.0.1:8080/.
  2. Create a build by running npm run build and then open dist/index.html in your browser.

If you want access to your Vue app within the browser console, you could do the following:

import { createApp } from 'vue';
import App from './App.vue';


const app = createApp(App);

// now you can see `vueApp` within the browser console
window.vueApp = app;

app.mount('#app');

Upvotes: 3

Related Questions