component and slot
component and slot
使用:
1.component panel
2.其中header和body需要传入变量
3.views.components.index 中 需要引用component模版panel
@component('components.panel')
@slot('title')
hello world
@endslot
@slot('content')
have a nice day
@endslot
@endcomponent
4.如果要传入默认content
panel.blade.php修改如下:
index.blade.php修改如下
@component('components.panel')
@slot('title')
hello world
@endslot
have a nice day
@endcomponent
//可多来几个:
@component('components.panel')
@slot('title')
hello world
@endslot
have a nice day123
@endcomponent
5.还可以这样给默认值:title默认为laravel
panel.blade.php修改如下:
index.blade.php修改如下
@component('components.panel')
have a nice day
@endcomponent

浙公网安备 33010602011771号