数组映射

_self.accuserList = res.data.data.accuser.map((arr)=>{
if (arr.userType == 1){
arr.userType = "自然人"
}if (arr.userType == 2){
arr.userType = "法人公司"
}if (arr.userType == 3){
arr.userType = "司法组织"
} })
可写成:
_self.accuserList = res.data.data.accuser.map((arr)=>{
const type = ['', '自然人', '法人公司', '司法组织']
arr.userType = type[arr.userType]
})
return arr
})

        数据解析采用数组映射一一对应,
posted @ 2019-01-30 17:14  -http  阅读(559)  评论(0编辑  收藏  举报