在生产模式(在服务器上)下,我的网站在 Chrome 控制台中出现错误:
Uncaught(承诺)错误:找不到页面:./Pages/Posts/Show.vue
此外,仪表板页面不会根据我在本地开发中引入的文本和新分页表的更改进行更新。
本地一切正常,但推送到 Digital Ocean Server 不会显示最新更改。
我在线检查了源代码,他们的原始代码就在那里。我可以看到文本、分页表和新路线的变化。但当我加载网站时它们没有显示。我怀疑与缓存或构建过程有关?
我已经做到了:
php工匠缓存:clear
php工匠配置:clear
php工匠视图:clear
npm run build(新的 vite 版本资产)
有人可以帮忙吗?
共享文件:
资源/js/app.js
import './bootstrap';
import '../css/app.css';
import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
.mount(el);
},
});
InertiaProgress.init({ color: '#4B5563' });
后置控制器
<?php
namespace AppHttpControllersPost;
use AppHttpControllersController;
use IlluminateHttpRequest;
use InertiaInertia;
use AppModelsPost;
class PostController extends Controller
{
/**
* Display all posts
*
* @return InertiaResponse
*/
public function index(Request $request)
{
$posts = Post::paginate(10);
return Inertia::render('Dashboard', ['posts' => $posts]);
}
/**
* Display a post
*
* @return InertiaResponse
*/
public function show(Request $request, $id)
{
$post = Post::findOrFail($id);
return Inertia::render('Posts/Show', ['post' => $post]);
}
} Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这是一个 docker/nginx 问题。应用程序生成的文件未正确路由,因此原始版本中的静态文件不会被替换。
我改为使用卷在容器之间同步数据并且它起作用了。