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