2017-09-13 28 views
0

工作創建了一個模板文件夾中查看文件夾和header.blade.php並添加以下代碼Laravel @push不create_category.blade.php

<ul id="sidebar"> 
      @stack('sidebar') 
</ul> 

而創建內部意見另一category.blade.php文件夾,並添加以下代碼

@include('template/header') 
@push('sidebar') 
     <li>Sidebar first</li> 
@endpush 

回答

0

只能在外部佈局中定義A @stack。所以如果你想使用@push,你必須使用@extends('template.header')而不是@include('template.header')

在你的情況下,我不認爲這是可以使用@extends你可能使用其他佈局文件。

我在Laravel的問題搜索它,我發現這個Thread。也許這可以爲你澄清一些事情。

+0

謝謝我替換包括擴展它的工作 – nairsumesh1991

0
This can be particularly useful for specifying any JavaScript libraries required by your child views 

更好地使用@include insted的@push和@stack