[英]Laravel - blade append section
i need to run a js script in a subview, so i have a section with all my scripts and in the subview i try to append my script to the existing scripts.我需要在子视图中运行 js 脚本,所以我有一个包含所有脚本的部分,并且在子视图中我尝试将我的脚本附加到现有脚本中。
HTML PAGE:网页:
<html><head></head><body></body>@yield('scripts')</html>
SECTION:部分:
@section('scripts') <!-- my standard scripts --> @stop
SUBVIEW:小结:
@section('scripts') <!-- my new script --> @append
i already try with @parent inside subview @section('scripts') but doesn't work.我已经尝试在子视图 @section('scripts') 内使用 @parent 但不起作用。
thank's谢谢
You main view must have the scripts like this你的主视图必须有这样的脚本
@section('scripts')
// your scripts here
@show
Then you can use the @parent
tag to add scripts to the section
from the child template然后您可以使用
@parent
标签将脚本添加到子模板中的section
@section('scripts')
@parent
// your other scripts
@endsection
just read on blade templates laravel link bellow只需阅读下面的刀片模板 laravel 链接
<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>
example code for the parent part父部件的示例代码
@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
for the child view use the code above对于子视图,请使用上面的代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.