我想为我的项目创建模板。在我的项目中,我使用标题和css和js和页脚的所有页面。e page1.blade.php page2.blade.php等等)。在加载每个页面时,它需要更多的时间来加载。所以我需要创建一个共同的布局和加载内容(I。E page1.blade.php,page2.blade.php等)在内容部分
如何创建主布局和加载page1.blade.php和page2.blade.php等。我想创建链接this
<html>
<head>
<title>Title</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
你的page1.blade.php应该是这样的:
@extends('layouts.includes.default')
@section('content')
// Your content
@stop
你可以在Laravel文档中阅读关于刀片模板的内容:https://laravel.com/docs/5.2/blade
在您的资源文件夹中创建名为layout的子文件夹,并在其中创建文件master.blade.php例:资源->布局> master.blade.php
现在在您的page.blade.php中只要扩展它使用@extends (layout.master)
@extends('layouts.app')
@section('content')
<h2>Your Content </h2>
@endsection