在生產(chǎn)模式(在伺服器上)下,我的網(wǎng)站在 Chrome 控制臺(tái)中出現(xiàn)錯(cuò)誤:
Uncaught(承諾)錯(cuò)誤:找不到頁(yè)面:./Pages/Posts/Show.vue
此外,儀表板頁(yè)面不會(huì)根據(jù)我在本機(jī)開發(fā)中引入的文字和新分頁(yè)表的變更進(jìn)行更新。
本地一切正常,但推送到 Digital Ocean Server 不會(huì)顯示最新變更。
我在線上檢查了原始程式碼,他們的原始程式碼就在那裡。我可以看到文字、分頁(yè)表和新路線的變化。但當(dāng)我加載網(wǎng)站時(shí)它們沒(méi)有顯示。我懷疑與快取或建置過(guò)程有關(guān)?
我已經(jīng)做到了:
php工匠快?。篶lear
php工匠配置:clear
php工匠視圖:clear
npm run build
(新的 vite 版本資產(chǎn))
有人可以幫忙嗎?
共享檔案:
資源/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]); } }
這是一個(gè) docker/nginx 問(wèn)題。應(yīng)用程式產(chǎn)生的檔案未正確路由,因此原始版本中的靜態(tài)檔案不會(huì)被取代。
我改為使用卷在容器之間同步資料並且它起作用了。