【问题标题】:create layout for template in laravel 5.3在 laravel 5.3 中为模板创建布局
【发布时间】:2016-10-04 15:33:19
【问题描述】:

我想为我的项目创建模板。在我的项目中,我为所有页面使用页眉和 css 以及 js 和页脚。(即 page1.blade.php、page2.blade.php 等)。同时加载每个页面加载需要更多时间。所以我需要创建一个通用布局并在内容部分加载内容(即 page1.blade.php、page2.blade.php 等)。

如何创建主布局并加载page1.blade.php和page2.blade.php等。我想创建链接这个

<html>
<head>
    <title>Title</title>
</head>
<body>
    @section('sidebar')
        This is the master sidebar.
    @show

    <div class="container">
        @yield('content')
    </div>
</body>

【问题讨论】:

    标签: php html laravel


    【解决方案1】:

    这就是你的 page1.blade.php 的样子:

    @extends('layouts.includes.default')
    
    @section('content')
    
    // Your content
    
    @stop
    

    你可以在 Laravel 文档中了解 Blade 模板:https://laravel.com/docs/5.2/blade

    【讨论】:

    • 如何创建路由?
    • 您可以在 Route.php 文件中键入 Route::method('url','Controller@action')。但我建议去laracasts.com 并通过几个初学者系列。
    【解决方案2】:

    在您的资源文件夹中按名称布局创建子文件夹,然后您创建一个文件 master.blade.php 例如:资源->布局->master.blade.php

    现在在你的 page.blade.php 只是扩展它 使用 @extends('layout.master')

    【讨论】:

    • 如何创建路由?
    【解决方案3】:
    @extends('layouts.app')
    
    @section('content')
    
    <h2>Your Content </h2>
    
    @endsection
    

    【讨论】:

    • 如何创建路由>?
    • Route::method('url','Controller@action')
    • Route::get('/', function () { return view('welcome'); })->name('welcome');
    • Route::get('blade', function () { return view('child'); });我在 FileViewFinder.php 第 137 行捕获了 InvalidArgumentException:
    猜你喜欢
    • 2013-05-03
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    相关资源
    最近更新 更多