简体   繁体   English

Laravel - 刀片附加部分

[英]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 链接

I've read on this link我读过这个链接

<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.

相关问题 Blade View Laravel上的Javascript附加行 - Javascript on Blade View Laravel Append Row @include Laravel Blade 模板使用 Javascript 附加 - @include Laravel Blade Template to append using Javascript Laravel - javascript 在 @section 刀片内不起作用(文件输入) - Laravel - javascript doesn't work inside @section blade (file input) 使用jQuery在Laravel Blade中的选项中附加选定的下拉值 - Append Selected Drop Down Value with Option in Laravel Blade with Jquery 使用 JavaScript 将 Laravel 刀片模板附加/添加到当前视图 - Append/Add Laravel blade template to current view using JavaScript 在 laravel 刀片指令 @section.... @end visualstudio 代码中的部分是否有扩展或方法来正确突出显示代码? - Is there a extension or a way to highlight corretly code in laravel blade directive @section .... @end section in visualstudio code? Jquery append 和 Laravel:没有第一个开始就不能结束一个部分 - Jquery append with Laravel: Cannot end a section without first starting one 如何从主刀片视图获取追加文本框名称并将其插入laravel中的控制器 - how to get append textbox name from main blade view and insert into controller in laravel 如何在 Laravel 刀片文件中使用 jquery 将选项附加到动态创建的选择元素 - How to append options to dynamically created select elements with jquery in Laravel blade file 将刀片文件追加到jquery函数 - Append blade file to jquery function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM