Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.1k views
in Technique[技术] by (71.8m points)

vue中使用v-for进行循环undefined会导致该元素标签都没了

### 问题描述
若ratings.labels为undefined
相关代码
<div class="labels-view">
<span class="item":class="{'heigligh':item.label_star>0}" v-for="(item,index) in ratings.labels" :key="index">

{{item.content}}{{item.label_count}}

</span>
</div>

v-for进行循环{}与undefined是会跳过不执行因此预想解果是 {{item.content}}{{item.label_count}}这个字符串

但实际中是连<span><span>这个标签不进行都没有


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

没懂你的问题 你循环的labels 没有就不循环了就是没有啊。。你想要的情况是啥


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...