尝试在Laravel中显示表格时遇到问题。我的数据为JSON,这是我的web.php
Route::get('/', function () {
$values = (Redis::lrange('VIN',1,1));
for ($i = 1; $i<2 ; ++$i){
if(isset($values[$i])){
$values[$i] = json_decode($values[$i],true);
}
}
return view("welcome",['values' => $values]);
});
这是我的观看课:
<body>
<table class="table table-bordered table-striped" style="text-align:center; width: 600 px; margin:auto">
<thead align="center">
<tr>
<th>VIN</th>
<th>accelerator_throttle_pos_e</th>
<th>engine_load</th>
<th>maf_airflow</th>
<th>latitude</th>
<th>bearing</th>
<th>catalyst_temp</th>
<th>relative_throttle_pos</th>
<th>fuel_level_input</th>
</tr>
</thead>
<tbody>
@foreach ($values as $car)
<td> {{ $car['VIN'] ?? "" }} </td>
<td>{{ $car['accelerator_throttle_pos_e'] ?? ""}} </td>
<td>{{ $car['engine_load'] ?? ""}} </td>
<td>{{ $car['maf_airflow'] ?? ""}} </td>
<td>{{ $car['latitude'] ?? ""}} </td>
<td>{{ $car['bearing'] ?? ""}} </td>
<td>{{ $car['catalyst_temp'] ?? ""}} </td>
<td>{{ $car['relative_throttle_pos'] ?? ""}} </td>
<td>{{ $car['fuel_level_input'] ?? ""}} </td>
</tr>
@endforeach
</tbody>
</table>
</body>
没有显示任何表格,我只得到一个空白页,其顶部位于: VIN accelerator_throttle_pos_e engine_load maf_气流纬度轴承催化剂_temp relative_throttle_pos fuel_level_input
我需要知道我要去哪里错了。 提前非常感谢。