我使用过拉拉维尔刀片模板进行布局,但确实有效

  • 本文关键字:布局 有效 laravel
  • 更新时间 :
  • 英文 :


>Template:

<!DOCTYPE html>
<html>
<head>
<title>App Name @yield('title')</title>
</head>
<body>
@section('content')
</div>
</body>
</html>

视图:

@section('content')
@if(session('message'))
<p>{{session('message')}}</p>
@endif
@foreach ($posts as $post)
<h2><a href="{{url('/posts/show/'.$post->id)}}"> {{$post->title}}</a></h2>
<p>{{$post->body}}</p>
<a href="{{url('/posts/'.$post->id.'/edit')}}">Edit</a>
<a href="{{url('/posts/'.$post->id.'/delete')}}">Delete</a>
@endforeach
@endsection

我已经使用了这段代码并得到白屏如何解决这个问题 使布局文件夹和布局文件仅获得白屏,没有任何错误和输出

MASTE PAGE:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="csrf-token" content="{{csrf_token()}}">
@yield('metas')
@yield('head')
@yield('style')
</head>
<title>@yield('title')</title>
<body class="skin-blue sidebar-mini">
@yield('body')
</body>
<footer>
@yield('footer')
@yield('script_whole')
</footer>
</html>

子页面:

@extends('path.to.master_page')
@section('head') 
//head elemetns here
@endsection
@section('style') 
//style here
@endsection
@section('title', 'my_title')
@section('content')
//content elemetns here
@endsection
@section('footer')
//footer elemetns here
@endsection
@section('script_whole')
//scripts here
@endsection

现在每个页面都extendsMASTER_page,所以应该使用@section

而不是使用

@section('content');

在主刀片文件使用

@yield('content');

相关内容

最新更新