gpt4 book ai didi

jquery - 如何在 Blade 模板 Laravel 中使用指令 @push

转载 作者:行者123 更新时间:2023-12-03 22:04:18 37 4
gpt4 key购买 nike

我只需要一页上的脚本。它应该在 jQuery 之后加载。我在index.blade中尝试过

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

然后我应该在我看来使用 @stack('custom-scripts') ?

最佳答案

您只需要以相反的方式进行操作,@push 应该位于 View 中,它将内容推送到父@stack 指令。

所以你的index.blade.php应该有一个:

@stack('custom-scripts')

您的 child View :

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

您还可以将 @parent 指令与 @section 一起使用,如下所示:

//index.blade.php
@yield('scripts')


//child.blade.php
@section('scripts')
@parent
<!-- The rest of your scripts -->
@endsection

如果您需要更多信息,我建议您查看documentation 。希望这对您有帮助。

关于jquery - 如何在 Blade 模板 Laravel 中使用指令 @push,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44674255/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com