Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k 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 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...