叶片附加部分
Laravel - blade append section
我需要在子视图中运行一个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,但不起作用。
谢谢
你的主视图必须有这样的脚本
@section('scripts')
// your scripts here
@show
然后您可以使用@parent
标记从子模板
section
添加脚本@section('scripts')
@parent
// your other scripts
@endsection
只在刀片模板上阅读
我读过这个链接
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
父部分的示例代码
@extends('layouts.app')
@section('title', 'Page Title')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<p>This is my body content.</p>
@endsection
子视图使用上面的代码
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- 如何在生成下载文件时显示加载动画
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- 无法在通过jQuery的ajax加载的页面中执行javascript
- Emberjs应用程序加载在除Index之外的所有路由上
- 在chrome.tabs.onCreated之后加载HTML页面
- 单击F5时如何停止页面加载
- HTML5音频加载和播放获胜'我不能在iPad上工作
- 跟踪在页面加载时应用内联样式的JavaScript
- 在使用Polymer'加载所有json文件后执行方法;s的核心ajax
- jQuery Lazy加载动画滚动
- Html页面上的多个Base64图像和平滑加载
- 如何创建带有插槽的vue js组件预加载程序
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- 如何使该数据在所有元素中加载
- Chrome扩展没有't在重新加载之前考虑期权价值
- 使用javascript在Flash中加载外部图像
- Ajax文件加载和<输入>文件加载
- 如何使用nodes和.createElement(“b”)将文本加粗
- 只隐藏JW播放器底部控件,不包含初始加载程序