首页 > 编程 > PHP > 正文

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

2019-11-21 19:42:37
字体:
来源:转载
供稿:网友

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

以上这篇Laravel 在views中加载公共页面的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表