0
我混合了Laravel tutorial的兩個例子,並接收結果,我希望你能幫助我理解。 我的路線文件是:Laravel <title>在<body>
Route::get('/', function() {
return view('child', ['name' => 'Samantha']);
child.blade.php是
@extends('layouts.master')
@section('title', 'Page Title')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@endsection
Hello, {{ $name }}.
@section('content')
<p>This is my body content.</p>
@endsection
而且master.blade.php是
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
輸出是
Hello, Samantha. This is the master sidebar. This is appended to the master sidebar. This is my body content.
頁源代碼是
Hello, Samantha.
<html>
<head>
<title>App Name - Page Title</title>
</head>
<body>
This is the master sidebar.
<p>This is appended to the master sidebar.</p>
<div class="container">
<p>This is my body content.</p>
</div>
</body>
</html>
檢查工具顯示我空<head>
和<title>
在<body>
。
爲什麼會出現這種情況與Hello, {{ $name }}
以及爲什麼檢測工具對我說謊頁身?
而且,如果我把@section Hello, {{ $name }}
都看起來不錯。