猿问

js 数组取值问题

https://img2.mukewang.com/5c9dcaf6000123f108000074.jpg

数组
["{"status":true", ""contacts":[{"firstName":"育良"", ""lastName":"陈"", ""fullName":"陈育良"", ""id":1", ""phones":[{"呼叫手机":"134 3492 5770"}]}", "{"firstName":"慈娟"", ""lastName":"陈"", ""fullName":"陈慈娟"", ""id":3", ""phones":[{"呼叫手机":"134 3490 5123"}]}", "{"firstName":"宋卿"", ""lastName":"郑"", ""fullName":"郑宋卿"", ""id":4", ""phones":[{"广州":"178 7689 6767"}", "{"汕头":"135 3123 7336"}]}", "{"firstName":"练"", ""lastName":"教"", ""fullName":"教练"", ""id":5", ""phones":[{"呼叫手机":"158 1956 7883"}]}", "{"firstName":"哥"", ""lastName":"帅"", ""fullName":"帅哥"", ""id":7", ""phones":[{"呼叫手机":"130 2567 7186"}]}", "{"firstName":"仪"", ""lastName":"晓"", ""fullName":"晓仪"", ""id":9", ""phones":[{"呼叫手机":"137 2511 9946"}]}", "{"firstName":"丽萍"", ""lastName":"钟"", ""fullName":"钟丽萍"", ""id":11", ""phones":[{"呼叫手机":"135 3328 2964"}]}", "{"firstName":"东"", ""lastName":"房"", ""fullName":"房东"", ""id":12", ""phones":[{"呼叫手机":"138 2621 1985"}]}", "{"firstName":"瓜龙"", ""lastName":"麻"", ""fullName":"麻瓜龙"", ""id":13", ""phones":[{"呼叫手机":"135 8064 7346"}]}", "{"firstName":"乡"", ""lastName":"老"", ""fullName":"老乡"", ""id":14", ""phones":[{"呼叫手机":"134 3007 1412"}]}", "{"firstName":"欣"", ""lastName":"旭"", ""fullName":"旭欣"", ""id":17", ""phones":[{"呼叫手机":"177 2218 1780"}]}", "{"firstName":"阿里云客服"", ""fullName":"阿里云客服"", ""id":19", ""phones":[{"呼叫手机":"95187"}]}", "{"firstName":"文"", ""lastName":"耿"", ""fullName":"耿文"", ""id":20", ""phones":[{"呼叫手机":"132 0211 2514"}]}", "{"firstName":"沈"", ""fullName":"沈"", ""id":22", ""phones":[{"呼叫手机":"156 2622 2177"}]}", "{"firstName":"裕"", ""lastName":"康"", ""fullName":"康裕"", ""id":42", ""phones":[{"呼叫手机":"137 6071 2877"}]}", "{"firstName":"教练"", ""lastName":"肥肥"", ""fullName":"肥肥教练"", ""id":344", ""phones":[{"呼叫手机":"135 3927 3528"}]}", "{"firstName":"公交车服务"", ""fullName":"公交车服务"", ""id":357", 

问题:我想获取contacts里的所有值,但是获取不到,该怎么获取呢?


临摹微笑
浏览 1300回答 5
5回答

MMTTMM

这是字符串。。。JSON.parse()

婷婷同学_

你这个打印出来的值明显不是数组格式;我不知道后台返回你是什么格式,字符串吗?字符串的话,如果格式正确,用JSON.parse()转成json格式;再获取contacts

拉风的咖菲猫

vm.data4 = JSON.parse(vm.data4);

湖上湖

终于靠眼睛辨别法 发现了;你把一个多维数组 切割成了 下面这样的了""contacts":[{"firstName":"育良""""lastName":"陈""""fullName":"陈育良""

皈依舞

你这个是字符串吧,要转化成数组
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答