js array becomes an array object to get the solution for the last group

method

        private arr(){
            let obj = {};
            let param_arr_list = [
                {id:2,status:2}, //原数组本来挺多的 只做事列 因为只要id和status所以要组成一个新数组
                {id:3,status:2},
            ];
           

            for(let item of this.res_power_list){ // 这个表示后台返回来的原数组
                obj = {}; // 每一次循环要清空不然只能得到最后一组数据
                obj["status"] = item["status"];
                obj["userId"] = item["id]
                param_arr_list.push(obj)
            }
        }
        // 返回结果 [{status:"01",userId:2},{status:"02",userId:3}]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325835286&siteId=291194637