Add related attributes and attribute values in the array returned by the backend

statuname(){
      const params={
        'xxx':this.xxx
      }
      Statuname(params).then(res=>{
        this.xxx = res.data.data
        for(let i=0;i<this.xxx.length;i++){
        this.xxx[i].normalper=this.xxx[i].normal/this.xxx[i].sum*100                        
        this.xxx[i].waringCper=this.xxx[i].waringC/this.xxx[i].sum*100                  
        this.xxx[i].waringDper=this.xxx[i].waringD/this.xxx[i].sum*100
        //表示将后端返回的数组中其中的  一个属性值/另一个属性值*100 再重新赋值给一个新创建的属性
        }
      })
    },

Guess you like

Origin blog.csdn.net/weixin_58148116/article/details/128320194
Recommended