包含Laravel的布局



我的master.blade.php文件如下

<body>
@include('layouts.header')
@yield('content')
@include('layouts.footer')
@include('layouts.footer-script')
</body>

我的dashboard.blade.php文件如下

@extends('layouts.master')
// I would like to add Menu here
@section('content')
//more code here
@endsection

我的menu.blade.php如下图所示。

@extends('dashboard')
@section('menu')
// more HTML code
@endsection

如何在dashboard.blade.php中添加Menu

dashboard.blade.php文件如下

@extends('layouts.master')


@include('menu')

@section('content')

//more code here

@endsection

menu.blade.php如下图。

<div>

// more HTML code
</div>

如果你的菜单是静态的,就用include

仪表板文件

@extends('layouts.master')
@section('content')
@include('layouts.menu')
@endsection

和菜单文件将是(menu.blade.php)

<a href=''>Home</a>

master.blade.php

<body>
@include('layouts.header')
@yield('content')
@include('layouts.footer')
@include('layouts.footer-script')
</body>

dashboard.blade.php

@extends('layouts.master')
@include('menu')
@section('content')
//more code here
@endsection

这是你的代码。很好。如果是错误,我认为menu.blade.php.

的路径肯定是错误的。例:@include (frontend.menu)

谢谢你的回答。

最新更新