【问题标题】:Laravel - blade append sectionLaravel - 刀片附加部分
【发布时间】:2016-11-01 18:34:45
【问题描述】:

我需要在子视图中运行 js 脚本,所以我有一个包含我所有脚本的部分,在子视图中我尝试将我的脚本附加到现有脚本。

HTML 页面:

<html><head></head><body></body>@yield('scripts')</html>

部分:

@section('scripts') <!-- my standard scripts --> @stop

审阅:

@section('scripts') <!-- my new script --> @append

我已经尝试在子视图@section('scripts') 中使用@parent 但不起作用。

谢谢

【问题讨论】:

    标签: javascript laravel-5 blade


    【解决方案1】:

    你的主视图必须有这样的脚本

    @section('scripts')
        // your scripts here
    @show
    

    然后你可以使用@parent标签将脚本从子模板添加到section

    @section('scripts')
    @parent
        // your other scripts
    @endsection
    

    【讨论】:

      猜你喜欢
      • 2014-12-24
      • 2014-09-15
      • 2015-08-27
      • 2019-05-16
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      • 2018-05-02
      • 2014-11-13
      相关资源
      最近更新 更多