【问题标题】:Laravel Blade LayoutsLaravel 刀片布局
【发布时间】:2013-02-25 17:50:00
【问题描述】:

这是问题所在,它没有读取@layout()

在文件夹 View/authors/index.blade.php 内

@layout('layouts.default')

@section('内容')

作者主页

@endsection

在文件夹 Controllers/authors.php 中

类 Authors_Controller 扩展 Base_Controller{

  public $restful = true;

  public function get_index(){
      return View::make('authors.index')->with('title', 'Autores e Livros');
  }

}

在文件夹 View/layouts/default.blade.php 中

基本的html

<html>
<head> <title> {{ $title }} </title> </head>
<body>
{{ $content }}
</body>
</html>

我的错误在哪里?为什么不读?

【问题讨论】:

    标签: php frameworks laravel


    【解决方案1】:

    第一:内部视图/layouts/default.blade.php

    <html>
    <head> <title> {{ $title }} </title> </head>
    <body>
      @yield('content')
    </body>
    </html>
    

    第二个:更新

    我 99% 确定您的 View/authors/index.blade.php 中的 '@layout('layouts.default')' 不在第一行。它必须位于页面顶部。

    【讨论】:

    • 谢谢,为此 +1:"@layout('layouts.default')' 在您的 View/authors/index.blade.php 中不在第一行。它有位于页面顶部” 我刚刚花了两个小时想知道为什么我的布局没有呈现。我在文档或任何教程的任何地方都找不到这条重要的信息。我认为这一定是互联网上唯一实际存在这些信息的地方。
    • 我也遇到过这个问题。退格,它开始工作。你知道这是否是 laravel 4 的一个怪癖吗?
    【解决方案2】:

    似乎在 Laravel 4 中你应该使用 @extends('layouts.default') 而不是 @layout('layouts.default')

    【讨论】:

    • 在他的案例中,他使用的是 Laravel 3。您可以通过蛇形案例而不是骆驼案例来识别它。
    猜你喜欢
    • 2017-01-27
    • 1970-01-01
    • 2023-04-08
    • 2014-08-14
    • 2019-10-28
    • 2014-09-19
    • 2017-02-24
    • 2014-06-28
    • 2013-02-19
    相关资源
    最近更新 更多