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

  • 相关阅读:
    数据库分库分表(sharding)系列(五) 一种支持自由规划无须数据迁移和修改路由代码的Sharding扩容方案
    数据库分库分表(sharding)系列(三) 关于使用框架还是自主开发以及sharding实现层面的考量
    docker的入门简介
    nginx方向代理详解及配置
    nginx配置文件详解
    nginx安装
    iptables防火墙
    服务器加载过程
    服务器
    操作系统
  • 原文地址:https://www.cnblogs.com/polax/p/13300146.html
Copyright © 2011-2022 走看看