Hi so I'm new to vue and I have installed vue-cli globally and wonder why I get this Error :
Uncaught ReferenceError: Vue is not defined
at eval (Hello.vue?13ca:73)
at Object.<anonymous> (main.js:1061)
at __webpack_require__ (main.js:679)
at fn (main.js:89)
at eval (Hello.vue?549c:1)
at Object.<anonymous> (main.js:1049)
at __webpack_require__ (main.js:679)
at fn (main.js:89)
at eval (index.js?fc04:1)
at Object.<anonymous> (main.js:1035)
my main.js looks like this:
import 'bootstrap';
import Vue from 'vue';
import App from './App';
import router from './router';
Vue.config.productionTip = false;
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: {
App,
},
});
Since index.js is also referenced I also post the code for it :
import Vue from 'vue';
import Router from 'vue-router';
import Hello from '../components/Hello';
Vue.use(Router);
export default new Router({
routes: [
{
path: '/',
name: 'Hello',
component: Hello,
},
],
});
The error is because of this part in the Hello.vue file, when I delete this everything seems ok :
<script>
var nav = new Vue({
el: '#loginButtons',
methods: {
open: function(which, e) {
// Prevents clicking the link from doing anything
e.preventDefault();
}
}
});
</script>
Hello.vueshouldn't have anything likenew Vuein it. It's a component. See vuejs.org/v2/guide/single-file-components.html for examples.