Laravel 5 @推送(自定义脚本';)无法工作laravel

Laravel 5 @推送(自定义脚本';)无法工作laravel,laravel-5,laravel-blade,Laravel 5,Laravel Blade,在拉威尔我用的是脚本 @push('custom-scripts') <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> @endpush @push('custom-scripts') @端推 这不起作用,但如果改用pushonce方法 它正在工作,代码就像 @pushonce('custom-scripts') <script sr

在拉威尔我用的是脚本

@push('custom-scripts')
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
 @endpush
@push('custom-scripts')
@端推
这不起作用,但如果改用pushonce方法

它正在工作,代码就像

@pushonce('custom-scripts')
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
 @endpushonce
@pushonce('custom-scripts'))
@结束一次
为什么它不起作用?
如何解决这个问题?

您只需将其设置为相反的方式,@push应该位于子视图中,即将内容推送到父@stash指令。 因此,您的index.blade.php应该具有:

@stack('custom-scripts')
还有你的孩子观

@push('custom-scripts')
    <script type="text/javascript" src="{{ URL::asset ('js/custom-scripts.js') }}"></script>
@endpush
@push('custom-scripts')
@端推

您只需要做相反的事情,@push应该在子视图中,这就是将内容推送到父@stash指令。 因此,您的index.blade.php应该具有:

@stack('custom-scripts')
还有你的孩子观

@push('custom-scripts')
    <script type="text/javascript" src="{{ URL::asset ('js/custom-scripts.js') }}"></script>
@endpush
@push('custom-scripts')
@端推

No这里不起作用的是子视图`@push('custom-scripts')@endpush`和主刀片`@stack('custom-scripts')`No这里不起作用的是子视图`@push('custom-scripts')@endpush`和主刀片`@stack('custom-scripts')中的代码`