我有一个Laravel 5.7项目,该项目的刀片视图包含嵌套视图。在嵌套视图内部,我想产生一个在父刀片视图中定义的部分,但是该部分未在嵌套视图内部呈现。如何将节从父视图传递到嵌套视图,以使其在嵌套视图内呈现?
父视图-index.blade.php:
@section('content')
@include('../elements/admin-crud-tbl')
@endsection
@section('bonus-row-btns')
<v-btn title="Mark As Contacted" color="primary" fab small @click="updateContacted(props.item.id)" v-show="!props.item.contacted"><v-icon>check_circle_outline</v-icon></v-btn>
<v-chip small v-show="props.item.contacted" color="green" text-color="white"><v-icon>check_circle_outline</v-icon>Contacted!</v-chip>
@endsection
嵌套视图-admin-crud-tbl:
<td class="text-right align-middle">
@yield('bonus-row-btns')
<v-btn title="Edit" color="primary" fab small @click="edit(props.item.id)"><v-icon>edit</v-icon></v-btn>
<v-btn title="Delete" color="error" fab small class="text-white" @click="remove(props.item.id)"><v-icon>delete_outline</v-icon></v-btn>
</td>
如何获取“ bonus-row-btns”部分以在嵌套视图中正确呈现?
答案 0 :(得分:0)
您可以将该部分保存在单独的文件中,在视图目录中将其命名为btn.blade.php
。
btn.blade.php
@section('bonus-row-btns')
<v-btn title="Mark As Contacted" color="primary" fab small
@click="updateContacted(props.item.id)" v-show="!props.item.contacted"><v-icon>check_circle_outline</v-icon></v-btn>
<v-chip small v-show="props.item.contacted" color="green" text-color="white"><v-icon>check_circle_outline</v-icon>Contacted!</v-chip>
@endsection
现在您可以使用@include('btn')