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

  • 相关阅读:
    Action<T>和Func<T>委托
    异步委托学习笔记
    .Net身份验证里边的几个基本概念(转)
    线程和进程
    WebClient类的使用
    关于NHibernate的更新和读取操作,及碰见的一点问题
    ASP.NET MVC 中将数据从View传递到控制器中的三种方法(表单数据绑定)
    LINQ标准查询操作符学习笔记
    C#3.0中的扩展方法
    NHibernate中的一对多映射
  • 原文地址:https://www.cnblogs.com/polax/p/13300146.html
Copyright © 2011-2022 走看看