为了账号安全,请及时绑定邮箱和手机立即绑定

js 数组取值问题

js 数组取值问题

临摹微笑 2019-03-18 16:18:32
数组["{"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里的所有值,但是获取不到,该怎么获取呢?
查看完整描述

5 回答

?
MMTTMM

TA贡献1869条经验 获得超4个赞

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


查看完整回答
反对 回复 2019-03-29
?
婷婷同学_

TA贡献1844条经验 获得超8个赞

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

查看完整回答
反对 回复 2019-03-29
?
拉风的咖菲猫

TA贡献1995条经验 获得超2个赞

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


查看完整回答
反对 回复 2019-03-29
?
湖上湖

TA贡献2003条经验 获得超2个赞

终于靠眼睛辨别法 发现了;

你把一个多维数组 切割成了 下面这样的了

""contacts":[{"firstName":"育良""
""lastName":"陈""
""fullName":"陈育良""


查看完整回答
反对 回复 2019-03-29
?
皈依舞

TA贡献1851条经验 获得超3个赞

你这个是字符串吧,要转化成数组


查看完整回答
反对 回复 2019-03-29
  • 5 回答
  • 0 关注
  • 1299 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信