在vue js中缺少Route的必需参数

问题描述 投票:1回答:2

我想只调用一个用户ID的数据:我得到以下错误:

缺少[Route:VLead] [URI:VLead / {id}]所需的参数。 (查看:C:\ wamp64 \ www \ S2 \ resources \ views \ admin \ sidebar \ sidebar.blade.php)(查看:C:\ wamp64 \ www \ S2 \ resources \ views \ admin \ sidebar \ sidebar.blade。 PHP)

Route::get('/VLead/{id}', 'ClientController@index_lead')->name('VLead')->middleware('user');控制器

public function index_lead($id)
   {
     $clients = DB::table('clients')->where('Stage','<>',"Active" )
                                    ->orderBy('id', 'Aesc')
                                    ->get();
      return view('admin.VLead',compact('clients'));
   }
<script language="javascript" type="text/javascript">
          var scrt_var = {{ Sentinel::getuser()->id}}; 
</script>

<li><a class="" href="{{route('VLead')}} "onclick="location.href=this.href+'/'+scrt_var;return false;" >Leads</a></li>

laravel
2个回答
1
投票

您需要将{{route('VLead')}}更改为{{route('VLead', Sentinel::getuser()->id)}}或通过将id更改为Route::get('/VLead/{id}'使Route::get('/VLead/{id?}'参数可选


0
投票

您收到错误是因为您没有传递必需的参数。做这样的事情:

{{ route('VLead', ['id' => $userId]) }} 
© www.soinside.com 2019 - 2024. All rights reserved.