【发布时间】:2021-03-26 20:17:50
【问题描述】:
我在 Jetstream 中创建了一个 Livewire 组件,并在web.php 路由页面中将其设置为整页组件,如下所示:
use App\Http\Livewire\PostComponent;
...
Route::get('posts/',PostComponent::class)->name('posts');
post-component.blade.php文件原来有以下代码:
<div>
<h1>If you look to others for fulfillment, you will never truly be fulfilled.</h1>
</div>
如果我点击 URL .../posts 我会收到以下错误:
未定义变量:标头(查看: /home/vagrant/laravelapp/resources/views/layouts/app.blade.php)
所以我尝试在post-component.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>
<h1>If you look to others for fulfillment, you will never truly be fulfilled.</h1>
</div>
</x-app-layout>
不过,我得到了同样的错误。
我错过了什么?我该如何解决这个问题?
【问题讨论】:
-
检查插槽
header是否存在于组件x-app-layout中 -
谢谢。我正在检查 M Irfan 提供的 GitHub issue 链接。