2017-07-30 29 views
0

這是我的路線Laravel產量不工作

Route::get('/', '[email protected]'); 

這是我的應用程序頁面佈局

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>Dateneingabe</title> 

    <link rel="stylesheet" href="/css/app.css"> 
    <script src="{{asset('/js/jquery-3.2.1.min.js')}}"></script> 

</head> 
<body> 
    @yield('contentSpiel') 
    @yield('A') 
</body> 
</html> 

現在,這裏是我的@yield( 'contentSpiel')

@extends('app') 

@section('contentSpiel') 

      <div class="form-group"> 
       <label for="">Spiele</label> 
       <select class="form-control input-sm" name="spiele" id="spiele"> 

       @foreach($alleSpiele as $alleSpieleOutput)
  
        <option value="{!! $alleSpieleOutput->heimmannschaft !!}">{{$alleSpieleOutput->heimmannschaft}}</option>
  
       @endforeach 
       </select> 
      </div> 

<script> 
    $('#spiele').on('change', function(e){ 
     console.log(e); 

     var spielID = e.target.value; 

     //ajax 
     $.get('/spieler-table?spielID=' + spielID, function(data){ 

      //success data 
      console.log(data); 
     }); 
    }); 
</script> 

@endsection 

這裏是我的部分A

@extends('app') 

@section('A') 

<h2>asd</h2> 

@endsection 

我不明白爲什麼我只在我的瀏覽器中獲得@yield('contentSpiel')部分。我必須改變@yields在我的瀏覽器中?

+0

你爲什麼要擴展應用程序兩次?你是在控制器中結合兩個視圖還是什麼? – Ohgodwhy

回答

0

您只能從控制器加載一個視圖。現在,如果你有一個觀點,但你要得到它的多個部分,然後ü可以嘗試這個例子:

@extends('layouts.app') 


    @section('contentSpiel') 
    <div class="form-group"> 
    <label for="">Spiele</label> 
<select class="form-control input-sm" name="spiele" id="spiele"> 
@foreach($alleSpiele as $alleSpieleOutput) <option value="{!! $alleSpieleOutput->heimmannschaft !!}">$alleSpieleOutput->heimmannschaft}}</option>   
    @endforeach 
</select> 
    </div> 

    <script> 
    $('#spiele').on('change', function(e){ 
    console.log(e); 

    var spielID = e.target.value; 

    //ajax 
    $.get('/spieler-table?spielID=' + spielID, function(data){ 

    //success data 
    console.log(data); 
    }); 
    }); 
    </script> 
    @endsection 

    @section('A') 
    <h2>asd</h2> 
    @endsection 

現在如果你在一個視圖中打印您的價值,並希望加載像代爾酒吧另一種觀點認爲您主人然後只包括它。

這是我的應用程序頁面佈局

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>Dateneingabe</title> 

    <link rel="stylesheet" href="/css/app.css"> 
    <script src="{{asset('/js/jquery-3.2.1.min.js')}}"></script> 

</head> 
<body> 
    @yield('contentSpiel') 
    @include('your_view_file_path') 
</body> 
</html> 
0

佈局

<body> 
    @yield('contentSpiel') 
    @yield('A') 
</body> 

@stack('scripts') 

contecontentSpiel.blade.php視圖(這個觀點應該在行動上返回)

@extends('app') 

@section('contentSpiel') 

    <div class="form-group"> 
     ... 
    </div> 

@endsection 

@push('scripts') 
    <script> 
     $('#spiele').on('change', function(e){ 
      ... 
     }); 
    </script> 
@endpush 

@section('A') 
    ... 
@endsection 
,如果你想有幾個刀片文件

...你可以創建sectionAForContentSpiel.blade.php和移動這裏部分A碼

@section('A') 
    ... 
@endsection 

,然後在contecontentSpiel.blade.php使用:

@include('sectionAForContentSpiel') 

PS和@push('scripts') - @endpush您可以在頁面底部包含腳本。

0

我認爲你需要改變你的應用程序頁面佈局,如:

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>Dateneingabe</title> 

    <link rel="stylesheet" href="/css/app.css"> 
    <script src="{{asset('/js/jquery-3.2.1.min.js')}}"></script> 

</head> 
<body> 
    <section class="contentSpiel"> 

    @yield('contentSpiel') 

    </section> 


    <section class="A"> 

    @yield('A') 

    </section> 

</body> 
</html> 

希望這有助於爲你!