需求:v-for 同时遍历两个数组 应用场景: 服务器请求到文章信息,对于最近一个七天发表的文章需要显示new图标 ,服务器请求的信息中有文章发表信息,不过需要自己判断是否为最近七天内发表的文章。 1.判断是否为七天内,结果用数组保存 javascript">computed: { newIconIsShow: function() { let _this = this let item = this.itemInfo.articleList let arr = [] for (let i = 0; i < item.length; i++) { let res = compareTime(item[i].releaseTime, 99) arr.push(res) } console.log(arr) return arr } 2.v-for 遍历文章信息 javascript"><div class="list-item" v-for="(item,index) in itemInfo.articleList" :key="index" @click="newsClick(item.id)"> <div class="item-left"> <p class="text_p">. {{item.title}}</p> </div> <div class="item-right"> <new-icon v-show="newIconIsShow[index]"></new-icon> <span class="pubTime">{{item.releaseTime}}</span> </div> </div> v-for 遍历发布时间是否为七天内 总结: v-for 利用item 遍历一个数组 利用index 遍历另外一个数组