一对多关联查询返回[]数组,视图中if还能通过?

浏览:327 发布日期:2019/03/24
5.0.0 - 普通 - 已关闭
一对多关联查询,with(['attachments']),想实现如果不存在attachments则不显示外层DIV。但是if判断一致通过是个什么情况。经过打印$vo.attachments是值是[],但是还能通过if判断。{if !empty($vo.attachments)}
                            <div class="image-preview-wrapper d-flex">
                                {foreach $vo.attachments as $k => $v}
                                <div class="item">
                                    <img src="{$v.path}{$v.name}" alt="" />
                                </div>
                                {/foreach}
                            </div>
                            {/if}
评论(
后面还有条评论,点击查看>>