【发布时间】:2019-02-19 12:13:46
【问题描述】:
我正在使用 Laravel,当我尝试在控制器中返回视图时,页面上没有显示任何内容。
查看位置:/resources/views/search.blade.php
search.blade.php 的内容:
@extends( 'layouts.top10' )
@section( 'content' )
{{ $content }}
@endsection
布局中的代码无关紧要,因为它适用于许多其他页面。
控制器中的代码(如果我从控制器中回显 $content,它会显示在页面上,但不会显示视图或布局中的任何内容):
public function show( $keyword ) {
$keyword = urldecode( $keyword );
$keyword_no_slash = str_replace( '-', ' ', $keyword );
$page = Page::where( 'title', 'like', $keyword_no_slash )->first();
Self::showPage( $page );
}
public function showPage( $page ) {
$content = "Test content";
// If I echo $content here, it is shown on the page
return view( 'search', compact( 'content' ) );
}
路线:
Route::get( '/{keyword}', 'SearchController@showPage');
我的 /storage/logs/laravel.log 中没有错误
我的 /var/log/apache2/error.log 中没有错误
我已经尝试过多次清除我的 laravel 视图缓存和我的 cloudflare 缓存(加上它处于开发模式)-- 很多次。
除非我从控制器中回显,否则页面上没有任何内容。
似乎视图中的所有内容都被完全忽略了。我什至可以把应该出错的 php 代码输出,我得到的只是一个空白屏幕。
Laravel 框架 5.5.43
【问题讨论】: