我们可以使用section
来定义一些HTML,然后yield
在别的地方。刀片和刀片之间有什么区别?
那么,为什么我们有堆栈? https://laravel.com/docs/5.2/blade#stacks
它使用不同的关键字完成同样的事情,但有更少的选项(没有继承)。
@push('scripts')
<script src="/example.js"></script>
@endpush
<head>
<!-- Head Contents -->
@stack('scripts')
</head>
可与部分来完成:
@section('scripts')
<script src="/example.js"></script>
@endsection
<head>
<!-- Head Contents -->
@yield('scripts')
</head>
'@ section @ append'怎么样?我相信他们有同样的行为。 – Fortael