[英]Route to vue file from Laravel Jetstream Inertia
I'm trying to setup a route inside Laravel Jetstream using Inertia.我正在尝试使用 Inertia 在 Laravel Jetstream 中设置一条路线。 The route should be /bloglist.路由应该是/bloglist。
the vue file is located in /resources/js/Blog/BlogList.vue vue 文件位于 /resources/js/Blog/BlogList.vue
the route I am using is: Route::inertia('/bloglist', 'BlogList');
我使用的路线是: Route::inertia('/bloglist', 'BlogList');
When I open the route I get a blank page and an error当我打开路线时,我得到一个空白页面和一个错误
Unhandled Promise Rejection: Error: Cannot find module './BlogList.vue'未处理 Promise 拒绝:错误:找不到模块“./BlogList.vue”
What am I doing wrong?我究竟做错了什么?
The resolveComponent is set in the app.js. resolveComponent 在 app.js 中设置。 I don't believe it can be changed per route.我不相信它可以改变每条路线。 You can, however, add resources/js/Pages/Blog/BlogList.vue and call it with但是,您可以添加 resources/js/Pages/Blog/BlogList.vue 并使用
Route::inertia('/bloglist', 'Blog/BlogList');
Example app.js示例 app.js
new Vue({
render: (h) =>
h(InertiaApp, {
props: {
initialPage: JSON.parse(app.dataset.page),
resolveComponent: (name) => require(`./Pages/${name}`).default,
},
}),
}).$mount(app);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.