2016-06-29 57 views
0

我需要在子視圖中運行js腳本,因此我有一個包含所有腳本的部分,並且在子視圖中嘗試將我的腳本追加到現有腳本。Laravel-blade append部分

HTML頁面:

<html><head></head><body></body>@yield('scripts')</html> 

部分:

@section('scripts') <!-- my standard scripts --> @stop 

子視圖:

@section('scripts') <!-- my new script --> @append 

我已經與@parent嘗試子視圖@section內( '腳本'),但沒有按」工作。

感謝的

回答

0

您主視圖必須有這樣

@section('scripts') 
    // your scripts here 
@show 

腳本然後你可以使用@parent標籤腳本從孩子模板添加到section

@section('scripts') 
@parent 
    // your other scripts 
@endsection