从数组列表中获取数组值

时间:2014-09-17 13:28:08

标签: javascript coffeescript underscore.js

我有这段代码:

loadAccountTerms = (termsCode) ->
  if termsCode.length is 0 then return []
  hmgetPr( "buyers", termsCode )
    .then (accountTerms) ->
      console.log accountTerms
      terms = _(accountTerms).map( (pl,index) ->
        console.log pl["priceList"]
      )

console.log accountTerms返回

的位置

[ '{"srCode":"","accountCode":"SHO005","priceList":"CART","discount":0,"termDays":0}' ]

但是当我遍历这个并尝试返回priceList时,我得到了未定义。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

  

[   ' {" srCode":""" accountCode":" SHO005""价目表&#34 ;: " CART""折扣":0," termDays":0}'   ]

不是你应该做的。

尝试:

  

[   {" srCode":""" accountCode":" SHO005""价目表":" CART""折扣":0," termDays":0}   ]

这样,它是一个JSON对象,而不是一个字符串。

相关问题