• Laravel模板的继承


    将整个页面划分成不同的模块,

    代码部署:

    outesweb.php

    Route::get('section1',['uses'=>'StudentController@section1']);

    appHttpControllersStudentController.php

        //模板继承演示
        public function section1()
        {
            return view('student.section1');
        }

    esourcesviewslayouts.blade.php

    <html>
    <head>
        <meta charset="UTF-8">
        <title>学习laravel @yield('title')</title>
        <style>
            .header{
                width:1000px;
                height: 150px;
                margin: 0 auto;
                background: #f5f5f5;
                border: 1px solid #dddddd;
            }
            .main{
                width: 1000px;
                height: 300px;
                margin: 0 auto;
                margin-top: 15px;
                clear: both;
            }
            .main .sidebar{
                float: left;
                width: 20%;
                height: inherit;
                background: #f5f5f5;
                border: 1px solid #dddddd;
            }
            .main .content{
                float: right;
                width: 75%;
                height: inherit;
                background: #f5f5f5;
                border: 1px solid #dddddd;
            }
            .footer{
                width:1000px;
                height: 50px;
                margin: 0 auto;
                background: #f5f5f5;
                border: 1px solid #dddddd;
    
                text-align: center;
                position: absolute;
                bottom: 6;
    
    
            }
        </style>
    </head>
    <body>
        <div class="header">
            @section('header')
            头部
            @show
        </div>
        <div class="main">
            <div class="sidebar">
                @section('sidebar')
                侧边栏
                @show
            </div>
            <div class="content">
                @yield('content','主要内容区域')
            </div>
            <div class="footer">
                @section('footer')
                    底部
                @show
            </div>
        </div>
    
    </body>
    </html>

    esourcesviewsstudentsection1.blade.php

    section1
    @extends('layouts')

    子模板的继承

    esourcesviewsstudentsection1.blade.php

    section1
    @extends('layouts')
    
    @section('header')
        @parent
        header子模板
    @endsection
    
    
    @section('sidebar')
        @parent
        sidebar子模板
    @stop
    
    
    
    @section('title')
       我是title
    @stop
    
    @section('content')
        content
    @endsection

  • 相关阅读:
    poj3252(组合数)
    cf-Global Round2-E. Pavel and Triangles
    cf-Global Round2-D. Frets On Fire(二分)
    cf-Global Round2-C. Ramesses and Corner Inversion(思维)
    trick
    2019ICPC南京网络赛B super_log(a的b塔次方)
    欧拉定理,欧拉降幂
    F. Moving On
    Codeforces Round #200 (Div. 1)D. Water Tree
    hdu5452
  • 原文地址:https://www.cnblogs.com/polax/p/13300146.html
Copyright © 2020-2023  润新知