Php 拉维叶片@截面未显示
我有一个名为“home.blade.php”的刀片页面 home.blade.phpPhp 拉维叶片@截面未显示,php,laravel,frameworks,blade,Php,Laravel,Frameworks,Blade,我有一个名为“home.blade.php”的刀片页面 home.blade.php <doctype html> <html> <head> <title>{{$title}}</title> </head> <body> <!-- some other html here --> @section('content') @show
<doctype html>
<html>
<head>
<title>{{$title}}</title>
</head>
<body>
<!-- some other html here -->
@section('content')
@show
</body>
</html>
@extends('home')
@section('content')
<p>Page content goes here</p>
@endsection
控制器代码
Route::get('/', 'Controller@show')->name("home");
public function show()
{
return view("home", ['title' => "My Home"]);
}
我错过了什么 更新:我刚刚再次检查,您应该加载
内容
视图,而不是主页
布局
我认为您必须在home.layout.blade中定义@yield
而不是@section
<html>
<head>
<title>{{$title}}</title>
</head>
<body>
<!-- some other html here -->
@yield('content')
</body>
</html>
{{$title}}
@产量(‘含量’)
您可以从更新版中阅读更多内容:我刚刚再次检查,您应该加载内容
视图,而不是主页
布局
我认为您必须在home.layout.blade中定义@yield
而不是@section
<html>
<head>
<title>{{$title}}</title>
</head>
<body>
<!-- some other html here -->
@yield('content')
</body>
</html>
{{$title}}
@产量(‘含量’)
您可以从中阅读更多内容,为什么不尝试使用@yield
@yield('content')
希望这有帮助:)为什么不尝试使用@yield
@yield('content')
希望这有帮助:)Opps,我刚刚又检查了一遍。我认为在控制器的show()
操作中,您必须加载内容
视图,而不是主页
视图。耶!明白了@haidangyou应该叫“content”而不是home.blade.phpops,我刚刚又查过了。我认为在控制器的show()
操作中,您必须加载内容
视图,而不是主页
视图。耶!明白了@haidangyou应该调用'content'而不是home.blade.phpIt是因为内容在content.blade.php文件中而不是home.blade.php,尝试加载content.blade.php视图,您将看到文本。这是因为内容在content.blade.php文件中而不是home.blade.php中,尝试加载content.blade.php视图,您将看到文本