微信小程序怎么把后台拿到的数据中的id转换成前端可显示的文字?

微信小程序怎么把后台拿到的数据中的id转换成前端可显示的文字?

拿到了后端的数据接口,接口里面都是id值,我们前端要把id输出成相对的文字。想过用map,filter但是都不支持。请问有大神可以解决吗?


After getting the data interface of the back-end, there are all ID values in the interface. The front-end needs to output the ID into relative text. I've thought about using map and filter, but they don't support it. Is there a God who can solve this problem?

回答:

?:

list.forEach(item=>{

if(item.id == 1){

item.name = '张三'

}else if(item.id == 2){

item.name = '李四'

}else if(item.id == 3){

item.name = '王五'

}


})

七囍:谢谢
汝可识得此阵:

问负责人



硅谷小蛙:

问负责人

-EOF-