我有这段代码:
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
时,我得到了未定义。
我错过了什么?
答案 0 :(得分:0)
[ ' {" srCode":""" accountCode":" SHO005""价目表&#34 ;: " CART""折扣":0," termDays":0}' ]
不是你应该做的。
尝试:
[ {" srCode":""" accountCode":" SHO005""价目表":" CART""折扣":0," termDays":0} ]
这样,它是一个JSON对象,而不是一个字符串。