javascript - 未捕获的 ReferenceError: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 无法正常工作。我必须点击 auth 模块的 URL。
解决方案
之所以会发生这种情况,是因为这段代码。你没有声明route
变量。因此,它会引发错误。
Vue.mixin({
methods: {
route: route
}
});
推荐阅读
- wpf - 未找到 WPF MvxEventToCommand
- javascript - 如何自动将图像发送到服务器?
- exc-bad-access - 线程 1:EXC_BAD_ACCESS(代码=1,地址=0x40)
- angular2-template - 如何使用按钮单击隐藏一个 div 并显示另一个 div?
- freemarker - 为什么 .ftl 文件完全相同但文件大小不同?
- angular - 在 Promise 中返回 Observable
- c++ - stl中的比较器
- proxy - 从池中获取连接 - Envoy
- typescript - 传单地图不显示 GeoJSON 数据
- css - 如何将跨度放置在角度 4 中的 mat-icon 上并在 Click 上下拉