Bru*_*lva 1 php laravel laravel-5
我有以下控制器,将此信息数组传递给我的视图
public function index ()
{
public function index ()
{
$ information = [
'nroclients' => '10',
'nroservices' => '20',
'nrousuers' => '30',
'nroordensservices' => '40',
];
return view ('dashboard.index', compact ('information'));
}
}
Run Code Online (Sandbox Code Playgroud)
如何单独访问每个元素? index.blade.php
number of clients: {{information-> nroclients}} <br>
number of services: {{information-> nroservices}}
Run Code Online (Sandbox Code Playgroud)
这在我看来运行应该不起作用?
报告的错误是
(2/2)ErrorException试图获取非对象的属性(查看:C:\ wamp64\www\sistemtest\resources\views\panel\index.blade.php)
它的数组不是对象或json所以你应该在刀片中访问这样的键:
{{$information['nroclients']}}
Run Code Online (Sandbox Code Playgroud)
代替
number of clients: {{information-> nroclients}}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1089 次 |
| 最近记录: |