zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Online ddl 工具之pt-online-schema-change
    【MySql】mysql 慢日志查询工具之mysqldumpslow
    赶集网mysql开发36条军规
    MySQL数据库高并发优化配置
    mysql的表分区
    mysql 如果处理货币金钱类型
    bootstrab table+表格 select可编辑完整实例
    mongoDb 给表添加+ 删除字段
    mongoDb +Java+springboot
    java+数据库+D3.js 实时查询人物关系图
  • 原文地址:https://www.cnblogs.com/polax/p/13300146.html
Copyright © 2011-2022 走看看