员工= {Id: 1001,工资: 2000},{Id: 1002,工资: 1000};
预期结果:-我在浏览器上显示上面的数组。在一个函数点击,我想得到的工资乘以12。即年薪应该显示在网页上。但是,在函数单击上,我使用数组的map()将薪水相乘,然后将新计算的年薪推入salary属性
实际结果:-新计算的工资属性没有被推入到学生数组的属性中。
代码片段:-
map() {
    this.annualSalary = this.students.map(a => a.Salary *  12 );
    this.annualSalary.forEach((as, index) => {
      let asalary = as;   
      this.students.push({
        Salary : asalary,
      });
    });发布于 2019-11-07 19:57:19
以下是您的解决方案
    for (let index = 0; index < this.students.length; index++) {
      const element = this.students[index];
      this.students[index].Salary = element.Salary * 12
    }https://stackoverflow.com/questions/58748230
复制相似问题