在foreach使用if语句为什么不能循环输出?

在vue中,使用foreach循环数组里的每一条数据,其他的都没问题,但是在if语句里判断两个字段是否相等就不行了,都是只判断最后一条数据,请各位大神帮我看一下是怎么回事啊

tog() {        this.articleList.forEach((article) => {           
                    if (this.search === article.title) {    //就是这里的代码不能循环列表中的每一条数据
                console.log(article.title) 
                this.show = false; 
                this.flag = false;
                this.reveal = true;                
                this.resArr.push(article);
            } else {                
                  this.show = true;                
                  this.flag = true;                
                  this.reveal = false;
            }
        })
    }


慕瓜6365496
浏览 1787回答 3
3回答

Eilan

代码没问题啊。。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Vue.js