我的收益或部分不起作用是我的代码 我想我已经遵守了所有规则。如你所见,我想调用home.blade.php,我把它命名为@section(' content-page')并使用yield(')将其命名为main.blade.php。 content-page')但似乎产量或部分不起作用。以下是我的代码:
home.blade.php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [
'as' => 'home',
'uses' => 'PagesController@home'
]);
路线代码
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PagesController extends Controller
{
public function home()
{
return view('layouts.masters.main');
}
}
PageController
<!DOCTYPE html>
<html>
<head>
<title>
Forester | Home
</title>
<link rel="stylesheet" href="../custom/bootstrap/css/bootstrap.min.css">
<!-- <script src="../HCI/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script> -->
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="../custom/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="../custom/css/css.css">
</head>
<body>
<div class="col-xs-12">
@yield('page-content')
</div>
</body>
</html>
最后我的main.blade.php
rndb()
答案 0 :(得分:1)
不确定是否存在问题,但您错过@endsection
文件末尾的home.blade.php
标记
答案 1 :(得分:1)
在您的控制器中,您必须将返回值更改为“layouts.masters.home”(而不是“layouts.masters.main”)。
在你的视图目录中,你必须有一个名为“masters”的目录,在其中你必须有“main.blade.php”和“home.blade.php”