我只需要一页上的脚本。它应该在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')?
2条答案
按热度按时间toe950271#
您只需要以相反的方式进行设置,
@push
应该在child视图中,该视图将内容推送到父@stack
指令。所以你的index.blade.php应该有一个:
你的孩子观:
您也可以像这样使用
@parent
指令和@section
:如果你需要更多的信息,我建议你检查文档。希望这对你有帮助。
fslejnso2#
使用
@once
可能还有助于防止脚本执行多次。你可以定义你的根视图,让脚本有一个固定的位置,应该放在<head>
标签的末尾和<body>
标签的末尾:app.blade.php
:home.blade.php
: