简体   繁体   English

未捕获的 ReferenceError:Laravel 8 中未定义路由

[英]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.安装 Laravel 8 身份验证后,我在控制台中收到此错误。

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 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 ) 在 webpack_require (app.js:20) 在 app.js:84 在 app.js:87 app.js:58049

Download the Vue Devtools extension for better development.下载 Vue Devtools 扩展以获得更好的开发。 Due to this, my JavaScript is not working properly.因此,我的 JavaScript 无法正常工作。 I have to hit the URL for an auth module.我必须点击 URL 来获取身份验证模块。

in your Root Template (defaults to app.blade.php) ( details here ), add在您的根模板中(默认为 app.blade.php)(此处有详细信息),添加

@routes

before the line that calls app.js在调用 app.js 的行之前

It happens because of this code.之所以会发生这种情况,是因为这段代码。 You didnt declare route variable.你没有声明route变量。 Because of that it throws error.因此,它会引发错误。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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