【问题标题】:Laravel 5 - (@extends, @sections,...) not workingLaravel 5 - (@extends, @sections,...) 不工作
【发布时间】:2018-12-25 03:43:05
【问题描述】:

我是 Laravel 的新手,我在网站上尝试让所有 @xy 都不起作用,但我没有发现问题。我的 /home 代码如下:

@extends('layouts.app')

@section('content')
<h1>Home</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
@endsection

@section('sidebar')
  @parent
  <p>This is appended to the sidebar </p>
@endsection

/layouts/app.blade.php 的代码如下:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>FIXME</title>
    <link rel="stylesheet" href="/css/app.css">
  </head>
  <body>
    <div="app">
      @include('inc.navbar')

      <div class="container">
          @if(Request::is('/'))
          @include('inc.showcase')
          @endif
      </div>
      <div class="row">
      <div class="col-md-8 col-lg-8">
        @include('inc.messages')
        @yield('content')
      </div>
      <div class="col-md-4 col-lg-4">
        @include('inc.sidebar')
      </div>
    </div>
    </div>

    <footer id="footer" class="text-center">
      <p>Copyright 2018 &copy; FIXME </p>
    </footer>
  </body>
</html>

导航栏是一个引导模板。

【问题讨论】:

  • 你收到错误了吗?
  • 你使用的是哪个 laravel 版本?
  • 显示你的路线,控制器,你在哪里调用视图?
  • &lt;div="app"&gt; 似乎不是有效的 html
  • 你确定你保存的文件是双扩展名:.blade.php 吗?例如:something.blade.php。除非您修改了应用程序的这一部分,否则主刀片是 master.blade.php。

标签: php html laravel laravel-5 laravel-blade


【解决方案1】:
<Doctype html>

<html>

<head>

   @include('includes.head')

</head>

<body>

<div class="container">

   <header class="row">

       @include('includes.header')

   </header>

   <div id="main" class="row">

           @yield('content')

   </div>

   <footer class="row">

       @include('includes.footer')

   </footer>

</div>

</body>

</html>

如果您仍然有问题或需要信息,请访问我的文章: 在 Laravel 中使用 Blade 模板引擎创建布局

【讨论】:

    猜你喜欢
    • 2017-10-25
    • 2018-08-11
    • 2016-01-18
    • 1970-01-01
    • 2016-05-15
    • 2017-06-08
    • 2015-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多