加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – 如何将数组传递给laravel 5.4中的@slot?

发布时间:2020-12-14 19:56:12 所属栏目:大数据 来源:网络整理
导读:我试图在我的布局中使用它,我突然想到使用Laravel 5.4 @slot的新功能. 只是想知道是否可以将阵列传递到插槽? @section('SampleSection') @component( 'mylayouts.partials.contentheader' ) @slot('title') Sample Title @endslot @slot('indexes') Pass ar
我试图在我的布局中使用它,我突然想到使用Laravel 5.4 @slot的新功能.

只是想知道是否可以将阵列传递到插槽?

@section('SampleSection')

            @component( 'mylayouts.partials.contentheader' )

                @slot('title')
                    Sample Title
                @endslot

                @slot('indexes')
                    Pass array here  // example [ 'a','b','c' ]
                @endslot

            @endcomponent

        @endsection
我需要同样的东西.

这可以作为暂时的解决方案,但不是最好的形式.

@component('component.tab.header')
    @slot('navs',[
        "a" => "Pepe","b" => "Maria"
    ])
@endcomponent

编辑:

最后,就我而言,我解决了这个问题:

@component('component-name')
    @slot('slot-name')
        Value1|Value2|Value2
    @endslot
@endcomponent

并在组件代码中:

@foreach(explode('|',$slot-name) as $value)
    The value is {{ $value }} <br/>
@endforeach

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读