【发布时间】:2023-03-28 16:20:01
【问题描述】:
我们一直在将 MVC 内容转换为与 Laravel 应用程序不同的包。我们仍然在实际应用程序中保留我们的布局,但问题是 包无法使用 @extends('layouts.mainlayout') 指令 方法来模板化我们可以在哪里呈现布局内的部分,如下所示:@ 987654322@ 使用部分指令。
这是应用程序设计的快照:
Laravel 应用程序
整个应用程序的主布局又名“主”页面
resources/views/layouts/mainlayout.blade.php
使用 mainlayout.blade.php 的应用程序视图示例
例如:resources/views/home/index.blade.php
@extends('layouts.mainlayout')
@section('title')
Home
@stop
@section('css')
@parent
<style>
.#alp{font-size: 12pt;}
</style>
@stop
@section('content')
<table id="alp" class="display" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
@stop
@section('custom_js')
<script>
$(document).ready(function() {
var t = $('#alp').DataTable( {
"responsive": true,
"scrollX": true,
"initComplete": function(){
CTSA.showRecordCount(t);
CTSA.Flags.initCompleteDt = true;
},
"fnDrawCallback":function(){
if(CTSA.Flags.initCompleteDt)
CTSA.showRecordCount(t);
}
});
} );
</script>
@stop
工作不正常
使用 mainlayout.blade.php 的包示例
例如:packages/testpackage/resources/views/test.blade.php
@extends('layouts.mainlayout.php')
@section('title')
Test Page
@stop
我可以让包使用布局,但我无法通过@extends('layouts.mainlayout') 让它以应有的方式使用它。目前它基本上只是将test.blade.php 视图填充到mainlayout.blade.php 布局中。
它基本上像这样使用 mainlayout.blade.php 模板:
资源/视图/布局/mainlayout.blade.php
@section('content')
Contents of view test.blade.php get crammed here
@stop
【问题讨论】:
标签: php laravel composer-php