Heim  >  Artikel  >  Backend-Entwicklung  >  laravel Blade视图文件使用什么作为文件扩展名

laravel Blade视图文件使用什么作为文件扩展名

PHPz
PHPzOriginal
2016-06-06 20:32:142655Durchsuche

laravel Blade视图文件使用什么作为文件扩展名

laravel Blade视图文件使用什么作为文件扩展名?

在laravel 中模板有强大的模板引擎是 Blade模板

所有 Blade 视图文件都将被编译成原生的 PHP 代码并缓存起来,除非它被修改,

否则不会重新编译,这就意味着 Blade 基本上不会给你的应用增加任何负担。

Blade 视图文件使用 .blade.php 作为文件扩展名,被存放在 resources/views 目录。

Blade模板有两个优点是模板继承跟区块;

继承布局

当定义视图是,可以使用Blade模板中@extends 命令来为视图指定应该 「继承」 的布局。

继承 Blade 布局的视图可使用 @section 命令将内容注入于布局的 @section中。

而「主」布局中使用 @yield 的地方会显示这些子视图中的 @section 间的内容:

@extends('layouts.app')
 
@section('title', 'Page Title')
 
@section('sidebar')
    @parent
 
    <p>这将追加到主布局的侧边栏。</p>
@endsection
 
@section(&#39;content&#39;)
    <p>这是主体内容。</p>
@endsection

  我们可以将公共的部分代码选择用继承的方式,比如说 头部   底部  或者是左侧边栏  右侧边栏及其他有公共部分的地方

更多相关知识,请访问PHP中文网

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn