質問
@includeを2回使い、view1, view2と表示したいです。
しかし、以下のコードの出力はview1のみ出力されます。
@includeは1度しか使えない仕様なのでしょうか?
- index.blade.php
php
1@extends('layouts.master') 2 3@section('content') 4 @include('view1') 5 @include('view2') 6@stop
ファイル構成
- master.blade.php
php
1<!DOCTYPE html> 2<html lang="ja"> 3 <head> 4 <meta charset="utf-8"> 5 <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"> 6 <title>test</title> 7 8 <link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> 9 <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/Swiper/4.2.6/css/swiper.min.css"> 10 </head> 11 12 <body> 13 <nav class="navbar navbar-expand-lg navbar-dark bg-primary"> 14 <a class="navbar-brand" href="/">test</a> 15 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation"> 16 <span class="navbar-toggler-icon"></span> 17 </button> 18 19 <div class="collapse navbar-collapse" id="navbarColor01"> 20 <ul class="navbar-nav mr-auto"> 21 <li class="nav-item"> 22 <a class="nav-link" href="#">Home</a> 23 </li> 24 </div> 25 </nav> 26 <div id="container"> 27 @yield('content') 28 </div> 29 30 <script src="//code.jquery.com/jquery-3.3.1.min.js"></script> 31 <script src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> 32 @yield('javascript') 33 </body> 34</html>
- index.blade.php
php
1@extends('layouts.master') 2 3@section('content') 4 @include('view1') 5 @include('view2') 6@stop
- view1.blade.php
php
1@extends('layouts.master') 2 3@section('content') 4<h1>view 1</h1> 5@stop
- view2.blade.php
php
1@extends('layouts.master') 2 3@section('content') 4<h1>view 2</h1> 5@stop
- routes/web.php
php
1<?php 2 3Route::get('/', function () { 4 return view('index'); 5}); 6
version
Laravel 5.6.2.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/05/13 08:40 編集