后端直接返回map格式,前端如何处理成数组
后端返回的数据格式如下:
处理:
JavaScript
getEntperise(){
this.axios.get('/entEnterprisearchives/entName')
.then(res => {
// console.log(res);
for(let i in res){
this.entList.push({
id:i,
entName:res[i]
})
}
// console.log("++",this.entList);
}, () => {
});
结果:
其实,”” 双引号内是属性或值(也就是i),: 冒号表示后者是前者的值(这个值可以是字符串、数字、也可以是另一个数组或对象)。