I wanted to setup a SPA using Laravel 5.4 and Vue2. I have following a tutorial (Jeffrey Way - Laracast). But i am getting this issue. Can not figure it out why this error in console?? :
Uncaught TypeError: Cannot set property 'app' of undefined
at VueRouter (app.js:3149)
at Object.<anonymous> (app.js:4266)
at __webpack_require__ (app.js:20)
at Object.<anonymous> (app.js:3343)
at __webpack_require__ (app.js:20)
at Object.<anonymous> (app.js:13749)
at __webpack_require__ (app.js:20)
at app.js:66
at app.js:69
Here is my code below :
app.js
import router from './routes';
import './bootstrap';
var app = new Vue({
el: '#root',
router
});
routes.js
import VueRouter from 'vue-router';
let routes = [
{
path: '/',
component: require('./views/Home')
}
];
export default VueRouter({
routes
});
bootstrap.js
import Vue from 'vue';
import VueRouter from 'vue-router';
import axios from 'axios';
window.Vue = Vue;
window.axios = axios;
Vue.use(VueRouter);
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest'
};
export default new VueRouter({
routes
});
add "new"
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