【发布时间】:2021-11-11 01:34:15
【问题描述】:
我想在 Laravel 路由中不使用控制器将数据从 page A 发送到 page B。 ( Laravel / VueJS3 / InertiaJS )
在我的第一页,我有这个方法:
// first.vue
tappedCourse(course: Course): void {
const data: secondParams = {
courseName: course.name,
};
Inertia.get("/second", data as any);
},
在我的路线上:
// web.php
Route::inertia('/second', 'Course/Second');
最后是我的第二页道具:
// second.vue
export default defineComponent({
props: {
courseName: {
type: String,
required: true,
default: "",
},
},
问题是第二页prop没有接收到值,但是如果我手动插入:
// web.php
Route::inertia('/second', 'Course/Second', [
"couseName" => "Inertia + Laravel"
]);
一切正常。
有什么方法可以在我的路线中获取“查询参数”吗?喜欢$courseName 并发送到我的second.vue 喜欢上面的代码。
注意:inertia.get 正在工作,因为我在 URL 中收到参数名称:值。
http://localhost:8000/second?name="Inertia + Laravel"
注意 2:我的偏好是 POST,但我没有在文档中找到如何使用 laravel 路由 ( Route::inertia )。
【问题讨论】:
标签: laravel vue.js laravel-8 vuejs3 inertiajs