laravel刀片中的多个延伸

laravel刀片中的多个延伸,laravel,Laravel,我需要这样做: @extends('layouts.dashboard') @section('content') <div class="container"> <div class="row col-md-10 custyle"> @extends('layouts.panel', ['title' => "Categories"] ) @section('content_panel') <

我需要这样做:

@extends('layouts.dashboard')

@section('content')
<div class="container">
    <div class="row col-md-10 custyle">
        @extends('layouts.panel', ['title' => "Categories"] )
        @section('content_panel')
            <table class="table table-striped custab">
                 ...
            </table>
        @stop
@stop
@extends('layouts.dashboard'))
@节(“内容”)
@扩展('layouts.panel',['title'=>“Categories”])
@节(“内容面板”)
...
@停止
@停止
问题是我的最终HTML格式不好

我应该怎么做才能导入几个部分,这样我就不必重复我的代码了


德克萨斯州

如果您想使用上述方法,则需要稍微重新排列代码。您还需要使用@include而不是@extends

像下面这样的

@include('layouts.panel', ['title' => "Categories"] )
您的最终代码可能看起来像

@extends('layouts.dashboard')

@section('content')
    <div class="container">
        <div class="row col-md-10 custyle">
            @include('layouts.panel', ['title' => "Categories"] )
        </div>
    </div>
@endsection

@section('content_panel')
    <table class="table table-striped custab">
             ...
    </table>
@endsection
@extends('layouts.dashboard'))
@节(“内容”)
@包括('layouts.panel',['title'=>“Categories”])
@端部
@节(“内容面板”)
...
@端部

您可以这样做,但不幸的是,这并没有像您期望的那样起作用。您可以使用刀片组件来帮助实现查询的目的

您可以创建一个组件并为内容保存一个点。例如,假设您有panel.blade.php

<div class='layout-panel'>
    {{$slot}}
</div>

{{$slot}
然后你可以把它作为一个组件,用你的内容填充这个位置

@extends('layouts.dashboard')

@section('content')
<div class="container">
    <div class="row col-md-10 custyle">
        @component('layouts.panel')

            <table class="table table-striped custab">
                 ...
            </table>
        @endcomponent
@endsection
@extends('layouts.dashboard'))
@节(“内容”)
@组件('layouts.panel')
...
@端部元件
@端部

希望这有帮助

如果您可以在示例中包含所有未关闭的元素,这将非常有用。但是在我的面板中,我需要放置动态内容,这就是为什么我认为include不太适合的原因