Thomas Hirsch
Thomas Hirsch

Reputation: 2346

How to import Vue.js correctly

I am starting with Vue.js, and I am wondering how to import it properly, in order to bundle it with Webpack. All the examples in the documentation seem to assume that a Vue object is already present.

This is what I tried:

const Vue = require('vue')

and also

const Vue = require('vue').Vue

and then

var app = new Vue({ <options> })

This file is then bundled with Webpack and referenced in my HTML index file. But I am getting this error in the browser (in both cases):

Uncaught TypeError: Vue is not a constructor

Upvotes: 2

Views: 1246

Answers (1)

Synamatics
Synamatics

Reputation: 136

I think the best way, if you are using ES6, is to use

import Vue from 'vue';
var app = new Vue({ <options> })

Upvotes: 2

Related Questions