代码如下:
//parent.blade.php 父级模板
<link rel="stylesheet" href="{{asset('css/app.css')}}"> //引入css文件
<h1>我是头部</h1>
@yield("mainBody")
<h1>我是底部的区域</h1>
// test1.blade.php 子级模板
@extends('home.parent') //加载父级模板文件
@section("mainBody") //对应区域的显示名称
今天是 {{$now}}
@endsection
//控制器
public function test(){
$now=date("Y-m-d H:i:s");
return view('home.test1',compact('now'));
}
显示效果