1. 模板文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title')</title>
<style>
.header{
width:100%;
min-height:100px;
background:gold;
}
.main{
width:100%;
min-height:400px;
}
.main .sidebar{
width:30%;
height:400px;
float:left;
background:yellow;
}
.main .content{
width:70%;
height:400px;
float:left;
background:green;
}
.footer{
clear:both;
width:100%;
min-height:100px;
background:blue;
}
</style>
</head>
<body>
<div class="header">
@section('header')
頭部.
section可以定義視圖變量,也可以在內部進行拓展.(命令定義一個內容區塊)
yield 只是聲明定義,不可拓展. ( “顯示指定區塊” 的內容。)
@show
</div>
<div class="main">
<div class="sidebar">
@section('sidebar')
側邊欄
@show
</div>
<div class="content">
@yield('content','主要內容區域')
</div>
</div>
<div class="footer">
@section('footer')
底部
@show
</div>
</body>
</html>
2. 要繼承的文件
@extends('layout')
<!-- 重寫頭部 -->
@section('header')
<!-- 繼承之前的 -->
@parent
<h1>重寫頭部</h1>
@stop
<!-- 使用 yield. 先定義section -->
@section('content')
content12
@stop
@section('title')
一拳超人
@stop
