Laravel 慣性 Vite
P粉262926195
P粉262926195 2024-01-16 11:21:07
0
1
416

在生產模式(在伺服器上)下,我的網站在 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]);
    }    
}

P粉262926195
P粉262926195

全部回覆(1)
P粉511985082

這是一個 docker/nginx 問題。應用程式產生的檔案未正確路由,因此原始版本中的靜態檔案不會被取代。

我改為使用卷在容器之間同步資料並且它起作用了。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!