【问题标题】:Uncaught ReferenceError: route is not defined in Laravel 8未捕获的 ReferenceError:Laravel 8 中未定义路由
【发布时间】:2021-03-26 19:07:12
【问题描述】:
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 在模块../resources/js/app.js (app.js:63273) 在 webpack_require (app.js:20) 在 Object.0 (app.js:63334) 在 webpack_require (app.js:20) 在 app.js:84 在 app.js:87 app.js:58049

下载 Vue Devtools 扩展以获得更好的开发。因此,我的 JavaScript 无法正常工作。我必须点击 auth 模块的 URL。

【问题讨论】:

  • app.js:63273 Uncaught ReferenceError: route is not defined at Module../resources/js/app.js (app.js:63273) at webpack_require (app .js:20) 在 Object.0 (app.js:63334) 在 webpack_require (app.js:20) 在 app.js:84 在 app.js:87 app.js:58049 下载用于更好开发的 Vue Devtools 扩展
  • 控制台错误
  • require.context 返回什么?如果它返回一个数组,你应该使用方括号:files[key]
  • 顺便说一句,如果你想删除你的 cmets,我已经在问题中添加了错误
  • 什么是等价的路线?我没有看到任何可以分配路线的东西。

标签: javascript vue.js laravel-8


【解决方案1】:

因为这段代码而发生。您没有声明 route 变量。因此,它会引发错误。

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

【讨论】:

  • 我必须声明的地方请提供示例代码
猜你喜欢
  • 2023-01-12
  • 2015-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-28
  • 1970-01-01
  • 2022-06-11
  • 2021-11-24
相关资源
最近更新 更多