[英]How to change layout for a full page render inline livewire component
我想為訪客和應用程序頁面使用內聯 livewire 組件。 默認情況下,我知道 livewire 會恢復為layout.app
,並且我知道您可以更新所有整頁渲染的默認布局。
我正在閱讀此文檔https://laravel-livewire.com/docs/2.x/rendering-components並且能夠使用僅具有blade
和.PHP
文件的常規方法使其工作。
public function render()
{
return <<<'HTML'
<div>
example page view
</div>
HTML;
}
是否可以從我們直接返回 HTML 的內聯組件中的文檔中執行此操作?
public function render()
{
return view('livewire.show-posts')
->layout('layouts.guest');
}
public function render()
{
return <<<'HTML'
<div>
example page view
</div>
HTML; ->layout('layouts.guest'); // something along the lines of this
}
不,這是不可能的。 您必須使用 view()->layout() 箭頭 function
也許你可以這樣使用它:
public function render()
{
$datas = [
'data' => 'example page view'
];
return view('livewire.show-posts', $data)
->layout('layouts.guest');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.