Laravel 在views中加载公共页面的实现代码

2020-09-03 12:10:59

1:我们使用了Blade模板,并创建一个layout作为通用的模板。将子页面作为yield输出:

<!-- store in resource/view/layout.blade.php --><!DOCTYPE html><html>  <head>    <title>Laravel 5 - @yield('title')</title>    <link rel="stylesheet" href="./style/page.css" rel="external nofollow" >    <script src="./js/jquery.min.js"></script>    <script src="./js/bootstrap.min.js"></script>  </head>  <body>    <header>    </header> @yield('content')     <footer>    </footer>   </body></html>

2: 在子页面使用

<!-- store in resource/view/index.blade.php -->@extends('layout') @section('title', 'test') @section('content')<style>  .pageText {    font-color : #00ff00;  }</style> <div>  Some Child Page</div> @endsection
相关文章 大家在看