【发布时间】:2021-08-25 21:59:10
【问题描述】:
我很困惑,我需要你的帮助,这是错误:
[Route: single.temp] [URI: singlepost/{name}] [Missing parameter: name] 缺少必需参数。 (查看:C:\Users\Toshiba\Desktop\working\mouhawla\resources\views\index.blade.php)
搜索栏:
<div class="search">
<form role="form" action="{{route('single.temp')}}">
<i class="fa fa-search"></i>
<div class="field-toggle">
<input type="text" name="name" class="search-form" autocomplete="off" placeholder="Search">
</div>
</form>
</div>
方法:
public function getPostByName($name) {
$products = DB::table('templates')
->where('name', $name)
->first();
return view('singlepost', compact('products'));
}
路线:
Route::get('/singlepost/{name}', 'App\http\controllers\TemplatesController@getPostByName')->name('single.temp');
最终视图:
<h1 style="text-align: center;">ACH-template</h1>
<table>
<tr>
<td><img src="/storage/{{$products->image_path}}"></td>
<td><img src="/storage/{{$products->image_path2}}"></td>
<td><img src="/storage/{{$products->image_path3}}"></td>
<td>
<p>
<h2 style="text-align:center;">{{$products->name}}</h2>
</br>
<p>{{$products->description}}</p>
</p>
</td>
</tr>
</table>
<a href="/storage/{{$products->file_path}}" class="btn btn-primary">
<button class="btn" style="width:100%">
<i class="fa fa-download"></i> Download
</button>
</a>
【问题讨论】:
-
您尝试过什么来解决此错误?据我所知,这不涉及 HTML 或 jQuery(因为您尚未共享任何与 jQuery 相关的代码),因此请分享有关连接的更多详细信息,或删除这些标签
标签: php html jquery laravel laravel-8