我有一个主文件welcome.blade.php
,在其中标记了这样的内容
<!DOCTYPE html>
<html>
<head>
<title>
@yield('title') // title from signup.blade.php
</title>
</head>
<body>
<!-- some content here -->
@yield('signup') // I'm loading this from signup.blade.php
<!-- some content here -->
</body>
</html>
我正在从page
目录中的signup.blade.php
加载注册layouts/signup.blade.php
。
signup.blade.php
页面的代码如下:
@include('welcome')
@section('title')
measurement
@endsection
@section('signup')
<div class="container">
<div class="row">
<div class="col-md-6">
<form action="">
<input type="text" class="form-control">
</form>
</div>
</div>
</div>
@endsection
文件的结构如下:
resources/views/welcome.blade.php
resources/views/layouts/signup.blade.php
但是当我加载title
时,既没有显示{strong>问题,也没有welcome.blade.php
出现。
注意:标题显示为sign up form
,不知道为什么?
我做错了什么,请帮助我。
答案 0 :(得分:2)
您的主模板 welcome.blade.php
<!DOCTYPE html>
<html>
<head>
<title>
@yield('title')
</title>
</head>
<body>
@yield('content')
</body>
</html>
现在,将使用此模板的任何页面都需要对其进行扩展。在您的情况下 signup.blade.php
@extends('welcome')
@section('title')
measurement
@endsection
@section('content')
<div class="container">
<div class="row">
<div class="col-md-6">
<form action="">
<input type="text" class="form-control">
</form>
</div>
</div>
</div>
@endsection