簡體   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
    }
});

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

下載 Vue Devtools 擴展以獲得更好的開發。 因此,我的 JavaScript 無法正常工作。 我必須點擊 URL 來獲取身份驗證模塊。

在您的根模板中(默認為 app.blade.php)(此處有詳細信息),添加

@routes

在調用 app.js 的行之前

之所以會發生這種情況,是因為這段代碼。 你沒有聲明route變量。 因此,它會引發錯誤。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM