3
這兩個關鍵字在刀片服務器上的主要區別是什麼,我發現它們做的是同樣的事情,但是......語法不同,但最主要的區別是什麼? 我正在使用@yield和@include,但沒有弄清楚,哪個更好用?我想在需要時加載css樣式,例如我想將樣式和選項分隔到導航欄中,並將單獨的css樣式分隔到在navbar.css,footer.css,i中定義的頁腳中想要包含在我的main.blade.php中,但是頁腳並不總是可見的?@yield和@include之間的差異Laravel Blade模板導入CSS
如何解決這個問題?我認爲是錯的,最好把所有的CSS都放到一個文件中? 性能如何?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="expires" content="-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title> Authentication system</title>
{{--custom css--}}
@yield('css')
{{HTML::style('css/bootstrap.min.css')}}
<!-- Custom styles for this template -->
{{HTML::style('css/navbar.css')}}
</head>
<body>
@if(Session::has('global'))
<p>{{Session::get('global')}}</p>
@endif
@include('layout.navigation')
@yield('content')
@yield('layout.footer')
和頁腳
@extends('layout.main')
@section('css')
@parent
{{HTML::style('css/footer.css')}}
@endsection
@section('footer')
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<
</div>
</div>
</footer>
@endsection
我的代碼不能正常工作。
可能重複的[Laravel-區別@yield和@section?](http://stackoverflow.com/questions/29070456/laravel-difference-between-yield-and-section) – 2015-04-03 10:54:02
也許,但我編輯爲更具體的信息。 – pvaitonis 2015-04-03 11:08:11
如果你想要特定的答案,你需要包含一些代碼。 – Bogdan 2015-04-03 11:15:20