Laravel 8 blade 文件未呈现但在我查看页面源代码时显示
Laravel 8 blade File not rendering but shows when I view page source
这是我的表演方式
public 函数显示($id){
$学生 = Student::find($id);
return view('students.student-detail', ['student' => $student]);
}
路线
Route::get('/', [LoginController::class, 'index']);
/* Dashboard routes */
Route::get('/dashboard', [DashboardController::class, 'index']);
Route::get('/student-info', [StudentController::class, 'dashboard']);
Route::get('/parent-info', [ParentController::class, 'dashboard']);
Route::get('/teacher-info', [TeacherController::class, 'dashboard']);
/* Student routes */
Route::get( '/students', [StudentController::class, 'index']);
//Route::get( '/student-detail/{id}', [StudentController::class, 'studentDetail']);
Route::get( '/student-detail/{id}', [StudentController::class, 'show']);
Route::get( '/admit', [StudentController::class, 'create']);
Route::post('/admit', [StudentController::class, 'store']);
Route::get('/admit/edit/{id}', [StudentController::class, 'edit']);
Blade View
@extends('layouts.app')
@section('content')
<div class="dashboard-content-one">
<!-- Breadcubs Area Start Here -->
<div class="breadcrumbs-area">
<h3>Students</h3>
<ul>
<li>
<a href="index.html">Home</a>
</li>
<li>Student Details</li>
</ul>
</div>
<!-- Breadcubs Area End Here -->
<!-- Student Details Area Start Here -->
<div class="card height-auto">
<div class="card-body" style="margin-top: -1.5rem;">
<div class="heading-layout1">
<div class="item-title">
<h3>About Me</h3>
</div>
<div class="dropdown">
<a class="dropdown-toggle" href="#" role="button"
data-toggle="dropdown" aria-expanded="false">...</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#"><i class="fas fa-eye text-orange-red"></i> View</a>
<a class="dropdown-item" href="admit/edit/"><i class="fas fa-cogs text-dark-pastel-green"></i> Update</a>
<a class="dropdown-item" href="#"><i class="fas fa-times text-orange-peel"></i> Suspend</a> </a>
</div>
</div>
</div>
<div class="single-info-details">
<div class="item-img">
<img src="img/figure/student1.jpg" alt="student">
</div>
<div class="item-content">
<div class="header-inline item-header">
<h3 class="text-dark-medium font-medium">{{$student->first_name . " " . $student->last_name}}</h3>
<div class="header-elements">
<ul>
<li><a href="#"><i class="far fa-edit"></i></a></li>
<li><a href="#"><i class="fas fa-print"></i></a></li>
<li><a href="#"><i class="fas fa-download"></i></a></li>
</ul>
</div>
</div>
<p>{{ $student->bio }}</p>
<div class="info-table table-responsive">
<table class="table text-nowrap">
<tbody>
<tr>
<td>Name:</td>
<td class="font-medium text-dark-medium">{{$student->first_name . " " . $student->last_name}}</td>
</tr>
<tr>
<td>Gender:</td>
<td class="font-medium text-dark-medium">{{$student->gender->name}}</td>
</tr>
<tr>
<td>Father Name:</td>
<td class="font-medium text-dark-medium">{{ $student->parents->first_name . " " . $student->parents->last_name }}</td>
</tr>
<tr>
<td>Mother Name:</td>
<td class="font-medium text-dark-medium">{{ $student->parents->spouse_first_name . " " . $student->parents->spouse_last_name }}</td>
</tr>
<tr>
<td>Date Of Birth:</td>
<td class="font-medium text-dark-medium">{{$student->dob}}</td>
</tr>
<tr>
<td>Religion:</td>
<td class="font-medium text-dark-medium">{{$student->religion->name}}</td>
</tr>
<tr>
<td>Father Occupation:</td>
<td class="font-medium text-dark-medium">{{$student->parents->occupation}}</td>}</td>
</tr>
<tr>
<td>E-mail:</td>
<td class="font-medium text-dark-medium">{{$student->email}}</td>
</tr>
<tr>
<td>Admission Date:</td>
<td class="font-medium text-dark-medium">{{$student->created_at}}</td>
</tr>
<tr>
<td>Class:</td>
<td class="font-medium text-dark-medium">{{$student->classes->name}}</td>
</tr>
<tr>
<td>Section:</td>
<td class="font-medium text-dark-medium">{{$student->section->name}}</td>
</tr>
<tr>
<td>Roll:</td>
<td class="font-medium text-dark-medium">{{$student->admission_id}}</td></td>
</tr>
<tr>
<td>Address:</td>
<td class="font-medium text-dark-medium">{{ $student->home_address }},{{$student->lga->name}},{{$student->state->name}} State</td>
</tr>
<tr>
<td>Phone:</td>
<td class="font-medium text-dark-medium">{{$student->phone}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Student Details Area End Here -->
@endsection
我正在将数据从学生传递到显示方法。当我 dd($students) 它 returns 数据 students/student-detail/1 e.t.c
但是当我取出转储并重新加载时,它变成空白。
所以我决定通过查看页面源代码来检查数据是否完全进入视图。当我这样做时,我会根据需要在相应的 html 元素中看到结果,但它不会呈现。
有人能帮忙吗?
试试这个
public function show($id){
$student = Student::find($id)->first();
return view('students.student-detail', ['student' => $student]);
}
public function show($id){
$student = Student::find($id)->first();
return view('students.student-detail',compact('student'));
}
参考访问此 url:https://www.geeksforgeeks.org/different-ways-for-passing-data-to-view-in-laravel/
导致空白屏幕的原因是页脚中 javascript 文件的简单声明。我打算使用 laravel 资产来包含项目依赖项。像;
scr = "{{assets('/js/another_directory/file.js')}}".
完成后,页面呈现。
这是我的表演方式
public 函数显示($id){ $学生 = Student::find($id);
return view('students.student-detail', ['student' => $student]);
}
路线
Route::get('/', [LoginController::class, 'index']);
/* Dashboard routes */
Route::get('/dashboard', [DashboardController::class, 'index']);
Route::get('/student-info', [StudentController::class, 'dashboard']);
Route::get('/parent-info', [ParentController::class, 'dashboard']);
Route::get('/teacher-info', [TeacherController::class, 'dashboard']);
/* Student routes */
Route::get( '/students', [StudentController::class, 'index']);
//Route::get( '/student-detail/{id}', [StudentController::class, 'studentDetail']);
Route::get( '/student-detail/{id}', [StudentController::class, 'show']);
Route::get( '/admit', [StudentController::class, 'create']);
Route::post('/admit', [StudentController::class, 'store']);
Route::get('/admit/edit/{id}', [StudentController::class, 'edit']);
Blade View
@extends('layouts.app')
@section('content')
<div class="dashboard-content-one">
<!-- Breadcubs Area Start Here -->
<div class="breadcrumbs-area">
<h3>Students</h3>
<ul>
<li>
<a href="index.html">Home</a>
</li>
<li>Student Details</li>
</ul>
</div>
<!-- Breadcubs Area End Here -->
<!-- Student Details Area Start Here -->
<div class="card height-auto">
<div class="card-body" style="margin-top: -1.5rem;">
<div class="heading-layout1">
<div class="item-title">
<h3>About Me</h3>
</div>
<div class="dropdown">
<a class="dropdown-toggle" href="#" role="button"
data-toggle="dropdown" aria-expanded="false">...</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#"><i class="fas fa-eye text-orange-red"></i> View</a>
<a class="dropdown-item" href="admit/edit/"><i class="fas fa-cogs text-dark-pastel-green"></i> Update</a>
<a class="dropdown-item" href="#"><i class="fas fa-times text-orange-peel"></i> Suspend</a> </a>
</div>
</div>
</div>
<div class="single-info-details">
<div class="item-img">
<img src="img/figure/student1.jpg" alt="student">
</div>
<div class="item-content">
<div class="header-inline item-header">
<h3 class="text-dark-medium font-medium">{{$student->first_name . " " . $student->last_name}}</h3>
<div class="header-elements">
<ul>
<li><a href="#"><i class="far fa-edit"></i></a></li>
<li><a href="#"><i class="fas fa-print"></i></a></li>
<li><a href="#"><i class="fas fa-download"></i></a></li>
</ul>
</div>
</div>
<p>{{ $student->bio }}</p>
<div class="info-table table-responsive">
<table class="table text-nowrap">
<tbody>
<tr>
<td>Name:</td>
<td class="font-medium text-dark-medium">{{$student->first_name . " " . $student->last_name}}</td>
</tr>
<tr>
<td>Gender:</td>
<td class="font-medium text-dark-medium">{{$student->gender->name}}</td>
</tr>
<tr>
<td>Father Name:</td>
<td class="font-medium text-dark-medium">{{ $student->parents->first_name . " " . $student->parents->last_name }}</td>
</tr>
<tr>
<td>Mother Name:</td>
<td class="font-medium text-dark-medium">{{ $student->parents->spouse_first_name . " " . $student->parents->spouse_last_name }}</td>
</tr>
<tr>
<td>Date Of Birth:</td>
<td class="font-medium text-dark-medium">{{$student->dob}}</td>
</tr>
<tr>
<td>Religion:</td>
<td class="font-medium text-dark-medium">{{$student->religion->name}}</td>
</tr>
<tr>
<td>Father Occupation:</td>
<td class="font-medium text-dark-medium">{{$student->parents->occupation}}</td>}</td>
</tr>
<tr>
<td>E-mail:</td>
<td class="font-medium text-dark-medium">{{$student->email}}</td>
</tr>
<tr>
<td>Admission Date:</td>
<td class="font-medium text-dark-medium">{{$student->created_at}}</td>
</tr>
<tr>
<td>Class:</td>
<td class="font-medium text-dark-medium">{{$student->classes->name}}</td>
</tr>
<tr>
<td>Section:</td>
<td class="font-medium text-dark-medium">{{$student->section->name}}</td>
</tr>
<tr>
<td>Roll:</td>
<td class="font-medium text-dark-medium">{{$student->admission_id}}</td></td>
</tr>
<tr>
<td>Address:</td>
<td class="font-medium text-dark-medium">{{ $student->home_address }},{{$student->lga->name}},{{$student->state->name}} State</td>
</tr>
<tr>
<td>Phone:</td>
<td class="font-medium text-dark-medium">{{$student->phone}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Student Details Area End Here -->
@endsection
我正在将数据从学生传递到显示方法。当我 dd($students) 它 returns 数据 students/student-detail/1 e.t.c
但是当我取出转储并重新加载时,它变成空白。
所以我决定通过查看页面源代码来检查数据是否完全进入视图。当我这样做时,我会根据需要在相应的 html 元素中看到结果,但它不会呈现。
有人能帮忙吗?
试试这个
public function show($id){
$student = Student::find($id)->first();
return view('students.student-detail', ['student' => $student]);
}
public function show($id){
$student = Student::find($id)->first();
return view('students.student-detail',compact('student'));
}
参考访问此 url:https://www.geeksforgeeks.org/different-ways-for-passing-data-to-view-in-laravel/
导致空白屏幕的原因是页脚中 javascript 文件的简单声明。我打算使用 laravel 资产来包含项目依赖项。像; scr = "{{assets('/js/another_directory/file.js')}}".
完成后,页面呈现。