2
我正在使用Laravel 5。 我想包括使用頁面不同的內容:腳本在頁面中停止工作,同時包含來自其他頁面的內容使用不同的腳本
@include('example_page_content_one')
@include('example_page_content_two')
每一頁我包括有自己的腳本。
@section('script')
<script>
</script>
@endsection
在瀏覽父頁,所有內容頁都包括在內,只有在example_page_content_two網頁腳本工作和其他腳本無論是在父和example_page_content_one不工作。
我在延長master.blade.php
在父母頁面。 在母版頁,我用
@yield('script')
有什麼辦法來解決這個不使用不同部分名。 即
在example_page_content_one
@section('scriptExampleOne')@endsection
在example_page_content_two
@section('scriptExampleTwo')@endsection
在主基片
@yield('scriptExampleOne')
@yield('scriptExampleTwo')
其工作的腳本!當我在主要內容中只顯示最後一個@included頁面的內容。如何解決這個問題? – shuvrow
我不確定我是否理解。如果你正在使用'@ include',那麼只有當你需要添加一些東西到一個不同的部分時,你才需要'@ section'作爲內容,如果這樣做有道理的話。 – hyarion