Jam*_*P27 3 inertiajs laravel vue.js laravel-jetstream
我已经设置了一个使用 Jetstream(惯性 js 堆栈)的 Laravel 8 安装。Jetstream 提供的所有视图都正常工作。
问题是当我创建一个呈现新 Vue 模板的新路由时,我在控制台中收到此错误:
app.js:30559 [Vue warn]: Error in created hook: "Error: Cannot find module './Test'"
我在 web.php 中创建的路由
Route::get('/test', function() {
return Inertia\Inertia::render('Test');
});
Run Code Online (Sandbox Code Playgroud)
“Test.vue”文件位于“resources/js/Pages”目录中。
<template>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Testing
</h2>
</template>
Run Code Online (Sandbox Code Playgroud)
应用程序.js
require('./bootstrap');
import Vue from 'vue';
import { InertiaApp } from '@inertiajs/inertia-vue';
import { InertiaForm } from 'laravel-jetstream';
import PortalVue from 'portal-vue';
Vue.use(InertiaApp);
Vue.use(InertiaForm);
Vue.use(PortalVue);
const app = document.getElementById('app');
new Vue({
render: (h) =>
h(InertiaApp, {
props: {
initialPage: JSON.parse(app.dataset.page),
resolveComponent: (name) => require(`./Pages/${name}`).default,
},
}),
}).$mount(app);
Run Code Online (Sandbox Code Playgroud)
知道为什么找不到 Test.vue 模板吗?
也许其他人像我一样来到这里 - 我必须在 Chrome 中打开开发者控制台并确保在Network选项卡中,我已经disable cache检查过。
最重要的是,必须进入我的服务器并php artisan optimize清除缓存的视图。
| 归档时间: |
|
| 查看次数: |
3929 次 |
| 最近记录: |