【问题标题】:How to change default layout in Laravel8, livewire2 app?如何更改 Laravel 8、livewire 2 应用程序中的默认布局?
【发布时间】:2021-11-25 11:58:17
【问题描述】:

我在 Laravel8,livewire2 中制作了 3 种布局: 资源/视图/布局/admin.blade.php,资源/视图/布局/frontpage.blade.php, resources/views/layouts/personal.blade.php 并删除了原始 layouts.app.blade.php。

但打开仪表板页面时出现错误:

View [layouts.app] not found. (View: /resources/views/dashboard.blade.php)

默认内容:

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Dashboard') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                <x-jet-welcome />
            </div>
        </div>
    </div>
</x-app-layout>
  1. 我可以在上面的文件中指定布局吗?

  2. 这里https://laravel-livewire.com/docs/2.x/rendering-components#page-components我读到了:

如果您想指定除 layouts.app 之外的默认布局, 您可以覆盖 livewire.layout 配置选项。

'布局' => 'app.other_default_layout'

但是我在我的项目中没有找到任何“livewire.layout”文件。如何创建它?

谢谢!

【问题讨论】:

    标签: laravel laravel-livewire jetstream


    【解决方案1】:

    您应该使用命令发布 livewire 配置文件

    php artisan livewire:publish --config
    

    接下来,你可以在config/livewire.php中找到它

    【讨论】:

    • 我使用命令 config/livewire.php 创建并修改:'layout' => 'layouts.frontend',并清除了所有缓存,但出现错误 View [layouts.app] not found。反正
    • 你能发布应用布局刀片组件吗???在那里寻找任何@extends 指令
    猜你喜欢
    • 1970-01-01
    • 2020-01-05
    • 2022-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 2021-11-02
    相关资源
    最近更新 更多