怎么解决vue里面第二个forEach不工作

js代码

//获取组织用户成绩列表
    getUserList() {
      this.listQuery.OrgId = this.temp.parentId;
      var _this = this;
      // this.listQuery.CourseId = this.Classvalue;
      // console.log(this.listQuery);
      //获取用户
      users.getList(this.listQuery).then((response) => {
        //连接查询
        this.userList = [];
        this.List = response.data;
        // 遍历成绩表
        this.List.forEach((item) => {
          console.log(this.ScoreList);
          this.ScoreList.forEach((item1) =>{
            console.log(item.id == item1.userId);
            if(item.id == item1.userId){//判断用户id和课程表里的id是否相等   
              item.scoreId = item1.id;
              item.score = item1.score;
              item.status = 200;
            }
          }); 
          if (item.score == undefined) {
            item.score = 0;
          }
          this.userList.push(item);
        });
        console.log(this.userList);
        _this.total = response.count;
      });
    },
    //获取成绩列表
    getScoreList() {
      this.ScoreList = [];
      queryClass
        .getCourseScore({ page: 1, limit: 500, key: undefined })
        .then((res) => {
          console.log(res.data);
          console.log(this.Classvalue);
          res.data.forEach((item) => {
            if (item.courseId == this.Classvalue) {
              this.ScoreList.push(item);
            }
          });
          console.log("这是成绩列表");
          console.log(this.ScoreList);
        });
    },

  //查询成绩
    queryScore() {
      this.getScoreList();
      this.getUserList();
    },

这是有时候点击查询会出现的效果
img

img

这是正常工作的效果
img

img

跟map 没关系


    //获取成绩列表
    getScoreList() {
      this.ScoreList = [];
      queryClass
        .getCourseScore({ page: 1, limit: 500, key: undefined })
        .then((res) => {
          console.log(res.data);
          console.log(this.Classvalue);
          res.data.forEach((item) => {
            if (item.courseId == this.Classvalue) {
              this.ScoreList.push(item);
            }
          });
          console.log("这是成绩列表");
          console.log(this.ScoreList);
        });
    },
 
  //查询成绩
    queryScore() {
      this.listQuery.OrgId = this.temp.parentId
      Promise.all([users.getList(this.listQuery), this.getScoreList()]).then(res=> {
        //连接查询
        this.userList = [];
        this.List = res[0].data;
        // 遍历成绩表
        this.List.forEach((item) => {
          console.log(this.ScoreList);
          this.ScoreList.forEach((item1) =>{
            console.log(item.id == item1.userId);
            if(item.id == item1.userId){//判断用户id和课程表里的id是否相等   
              item.scoreId = item1.id;
              item.score = item1.score;
              item.status = 200;
            }
          }); 
          if (item.score == undefined) {
            item.score = 0;
          }
          this.userList.push(item);

          console.log(this.userList);
          this.total = res[0].count;
      })
    },

没看到第二个forEach

把第一个或第二个forEach 换成map。