英文:
How to add several layout in Tailwind?
问题
我试图在我的Laravel项目中创建一个新的布局,遵循x-app-layout,但是我收到一个错误:无法找到组件[driven-layout]的类或视图。
我在resources/views/layout目录下创建了driven.blade.php文件。
但是我的Blade页面无法找到我的新布局。
我做错了什么?
英文:
I'm trying to create a new layout in my Laravel project following x-app-layout but I receive an error:
Unable to locate a class or view for component [driven-layout].
I've create in resources/views/layout dir my driven.blade.php.
But my blade page can't locate my new layout.
What I'm wrong?
答案1
得分: 1
要像使用x-app-layout
一样引用x-driven-layout
,您需要在现有的Blade文件之外创建一个名为app/View/Components/DrivenLayout.php
的文件。
// app/View/Components/DrivenLayout.php
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use Illuminate\View\View;
class DrivenLayout extends Component
{
/**
* 获取表示组件的视图/内容。
*/
public function render(): View
{
return view('layouts.driven');
}
}
英文:
To referance x-driven-layout
the same way as x-app-layout
is used, you will need to create a file in app/View/Components/DrivenLayout.php
in addition to your existing blade file.
// app/View/Components/DrivenLayout.php
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use Illuminate\View\View;
class DrivenLayout extends Component
{
/**
* Get the view / contents that represents the component.
*/
public function render(): View
{
return view('layouts.driven');
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论