我刚刚与Homestead开始了一个新的Laravel 5.3项目,我试图为我的网站设置一个非常简单的结构,但我遇到了一个意想不到的问题。
- resources
-- views
--- layouts
------- master.blade.php
--- partials
------- home.blade.php
------- about.blade.php
-- index.blade.php
master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>@yield('title')</title>
<!-- Bootstrap -->
<link href="{{URL::asset('css/app.css')}}" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@yield('content')
<script src="{{URL::asset('js/app.js')}}"></script>
</body>
</html>
出于某种原因,<head>
代码之间的内容会输出到<body>
代码中。
index.blade.php - 扩展主
@extends('layouts.master')
@include('partials.nav')
@section('content')
<p>yes</p>
@endsection
我该如何解决这个问题?
答案 0 :(得分:1)
@include('partials.nav')应该在master.blade.php中。在扩展模板时,Laravel采用有线策略放置包含的模板,当它没有产生时。