指点成金-最美分享吧

登录

VUE 模板 v-if 判断 数组是否为空

佚名 举报

篇首语:本文由小编为大家整理,主要介绍了VUE 模板 v-if 判断 数组是否为空相关的知识,希望对你有一定的参考价值。

vue 模板 v-if 判断数组是否为空 :

为空:array == undefined ||array == null || array.length <= 0     (顺序不能调换)不为空: array !==undefined && array != null  && array.length > 0   (顺序不能调换)

示例:

<ul v-if="commentList == undefined ||commentList == null || commentList.length <= 0 " >暂无评论!ul><ul v-if="commentList != undefined && commentList != null && commentList.length > 0 " ><li class="list-group-item"  v-for="(item,index) in commentList"  ><p class="username"> item.username  说:p><p class="content" > item.content p>li>ul>

以上是关于VUE 模板 v-if 判断 数组是否为空的主要内容,如果未能解决你的问题,请参考以下文章