简体   繁体   中英

Uncaught ReferenceError: route is not defined in Laravel 8

require('./bootstrap');
require('./ziggy');
window.Vue = require('vue');
const files = require.context('./', true, /\.vue$/i);
files.keys().map(key => {
    return Vue.component(_.last(key.split('/')).split('.')[0], files(key))
});
const app = new Vue({
    el: '#app',
})
Vue.mixin({
    methods: {
        route: route
    }
});

After installing Laravel 8 authentication, I get this error in the console.

app.js:63273 Uncaught ReferenceError: route is not defined at Module../resources/js/app.js (app.js:63273) at webpack_require (app.js:20) at Object.0 (app.js:63334) at webpack_require (app.js:20) at app.js:84 at app.js:87 app.js:58049

Download the Vue Devtools extension for better development. Due to this, my JavaScript is not working properly. I have to hit the URL for an auth module.

in your Root Template (defaults to app.blade.php) ( details here ), add

@routes

before the line that calls app.js

It happens because of this code. You didnt declare route variable. Because of that it throws error.

Vue.mixin({
methods: {
    route: route
}
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM