如何在sencha touch中获取价值形式记录 [英] How to get value form record in sencha touch
问题描述
我试图从嵌套的 json 中获取价值,但无法获取价值.我有以下数据结构.我正在打印记录.
I am trying to get value from nested json, but unable to get value. I have following data structure. Here I am printing record.
我做了什么.
onWordTap: function(view, index, target, record, event) {
var wordName=record.get('name');
console.log("Word--->>>>"+wordName);
console.log(record);
},
但我进入控制台是这样的:-> Word--->>>>undefined
but i get in console like this:-> Word--->>>>undefined
我也试过这个:
var wordName=record.data.get('name');
但是得到
未捕获的类型错误:对象 # 没有方法get"
我的 JSON 看起来是这样的:norelrn.
my JSON looks like this: JSON
我之前的问题也和这个类型的问题有关,请看.之前的问题
My previous question is also related to this type question, please watch . Previous Problem
推荐答案
我假设这是一个 DataView
或一个 List
,并且那个 onWordTap
是 itemtap
的监听器.
I am assuming this is a DataView
or a List
, and that onWordTap
is a listener for for itemtap
.
如果是这种情况,要从记录中获取数据,您只需要record.get('name')
.您还可以使用 record.get('definitions')[0].definition
(请注意,您已在代码中将其拼写为 defintion
- 当心).
If that is the case, to get data from records, you just need record.get('name')
. You can also use record.get('definitions')[0].definition
(note that you've spelled it defintion
in your code - beware).
这篇关于如何在sencha touch中获取价值形式记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!