gpt4 book ai didi

javascript - 页面中的脚本在使用不同脚本包含其他页面的内容时停止工作

转载 作者:行者123 更新时间:2023-11-29 21:42:01 26 4
gpt4 key购买 nike

我正在使用 Laravel 5 。我正在尝试使用以下方法在页面中包含不同的内容:

@include('example_page_content_one') 
@include('example_page_content_two')

我包含的每个页面都有自己的脚本。

@section('script')
<script>
</script>
@endsection

在浏览包含所有内容页面的页面时,只有example_page_content_two页面中的脚本在工作,其他脚本都在>parentexample_page_content_one 不工作。

我在 parent 页面中扩展 master.blade.php。在我使用的母版页中

@yield('script')

有没有办法在不使用不同的 section 名称的情况下解决这个问题。即

example_page_content_one

@section('scriptExampleOne')@endsection

example_page_content_two

@section('scriptExampleTwo')@endsection

在主 Blade 中

   @yield('scriptExampleOne')
@yield('scriptExampleTwo')

最佳答案

您需要使用@append 来结束您的脚本。如果您使用 @endsection,那么它将覆盖之前添加的任何内容。

所以:

@section('script')
<script>
</script>
@append

关于javascript - 页面中的脚本在使用不同脚本包含其他页面的内容时停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32451638/

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