如何在Tailwind中添加多个布局?

huangapple go评论144阅读模式
英文:

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
&lt;?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(&#39;layouts.driven&#39;);
    }
}

huangapple
  • 本文由 发表于 2023年3月9日 14:33:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75681161.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定