<div class="slh_pro_nav" id="slh_pro_nav">
<div class="slh_pro_nav_l">
<div class="slh_pro_nav_title">
<span class="slh_pro_nav_title2"><span name="_slh_pro_nav_title2|">全部产品</span></span>
</div>
<div class="slh_pro_nav_ul1">
<ul>
@foreach($submenus as $submenu1)
@if($submenu1->type=="产品&服务")
<li>
<a target="_blank" href='"/getProductList?type="{{$submenu1->subname}}"'>{{$submenu1->subname}}</a>
</li>
@endif
@endforeach
</ul>
</div>
</div>
<div class="slh_pro_nav_r">
<div class="slh_pro_nav_ul2">
@foreach($submenus as $submenu2)
@if($submenu2->type=="产品&服务")
<div class="slh_pro_nav_ul2_big">
<div class="slh_pro_nav_title3">{{$submenu2->subname}}</div>
<div class="slh_pro_nav_list">
<ul>
@foreach($productlist as $value)
@if($value->type==$submenu2->subname)
<li> <a target="_self" rel="nofollow" href="/{{$value->link}}" >{{$value->productname}}</a></li>
@endif
@endforeach
<li></li>
</ul>
</div>
</div>
@endif
@endforeach
</div>
</div>
有多个foreach使用了同一个参数,在后端查找数据库代码无误的前提下渲染时出现Trying to get property 'subname' of non-object的问题.
@foreach($params as $value)
<li>
{{@value}}
</li>
@endforeach
as后面的变量要使用不同的单词。保持良好的书写习惯,mark!