Laravel Jetstream Vue 混合路由 [英] Laravel Jetstream Vue mixin route

查看:37
本文介绍了Laravel Jetstream Vue 混合路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装程序使用 Jetstream 选项创建的新 Laravel 项目中,resources/js/app.js 有一行内容:Vue.mixin({ methods: { route } });

In a new Laravel project created by the installer with the Jetstream option resources/js/app.js has a line that reads: Vue.mixin({ methods: { route } });

PHPStorm 报告 route 是一个未解析的变量或类型.发生这种情况,PHPStorm 可能是错误的.在新创建的应用程序中,这不会导致错误.

PHPStorm reports that route is an unresolved variable or type. This happens, PHPStorm can be wrong. In a newly created application this does not cause an error.

但是,当我将现有项目升级到 Laravel 8.10.0 并通过 Composer 安装 Jetstream 时,这确实会导致和问题.运行这个npm run dev时不会报错,但是浏览器会报app.js:44258 Uncaught ReferenceError: route is not defined.

However, when I upgraded an existing project to Laravel 8.10.0 and installed Jetstream via composer this does cause and issue. When running this npm run dev does not error, but the browser will report app.js:44258 Uncaught ReferenceError: route is not defined.

我在 app.jsbootstrap.js 中找不到会导致这种情况的区别.这是从哪里导入或包含的,以便我可以检查它是否在我的升级中正确完成?

I can find no difference in app.js or bootstrap.js that would cause this. Where does this get imported or included so that I can check if it was done correctly in my upgrade?

推荐答案

新创建的应用程序和更新都创建了一个包含 @routes 指令的 Blade 模板.当我比较现有文件时,我没有注意到这种差异.

The newly created app and the update both create a Blade template that includes the @routes directive. As I was comparing existing files I did not notice this difference.

这可以通过在加载主脚本之前在您的刀片模板中包含 @routes 指令来纠正,如 ziggy 安装指南.

This can be corrected by including the @routes directive in your blade template prior to the main scripts being loaded, as documented in the installation guide for ziggy.

这篇关于Laravel Jetstream Vue 混合路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆