所以我有input.blade.php,它扩展了register.blade.php(它扩展了app.blade.php),但是我input.blade.php的@section('input.agent')中的内容却没有可以在我的register.blade.php中使用@yield('input.agent')看到,它位于卡主体选项卡窗格下(很难找到,但确实存在)。
这是我的register.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<div class="card">
<div class="card-header">
<nav>
<div class="nav nav-tabs card-header-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-agent-tab" data-toggle="tab" href="#nav-agent" role="tab" aria-controls="nav-agent" aria-selected="true">Agent</a>
<a class="nav-item nav-link" id="nav-development_officer-tab" data-toggle="tab" href="#nav-development_officer" role="tab" aria-controls="nav-development_officer" aria-selected="false">Development Officer</a>
</div>
</nav>
</div>
<div class="card-body">
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-agent" role="tabpanel" aria-labelledby="nav-agent-tab">@yield('input.agent')</div>
<div class="tab-pane fade" id="nav-development_officer" role="tabpanel" aria-labelledby="nav-development_officer-tab">Hello</div>
</div>
</div>
</div>
</div>
@endsection
这是我的input.blade.php
@extends('auth.register')
@section('input.agent')
<h1>Hello</h1>
@endsection
这是路由下的web.php
<?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('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
我的目录:
view=>auth=>register.blade.php
view=>input=>input.blade.php
view=>layouts=>app.blade.php
请帮助我 我在这里做什么错了?
答案 0 :(得分:0)
尝试使用@include
代替@yield
:
<div class="tab-pane fade show active" id="nav-agent" role="tabpanel" aria-labelledby="nav-agent-tab">@include('input.input')</div>
在您的register
视图中。
并删除:
@extends('auth.register')
@section('input.agent')
@endsection
在您的input
视图中(仅保留html)。
否则,您将必须返回input
视图而不是register
。