我可以在if语句中读取calcList1中的json,并认为我可以将它们推入l = []堆栈。我不确定我在这里缺少什么,因为我收到了错误。
错误:
"name": "TypeError",
"message": "'undefined' is not an object (evaluating 'l[0].z_param_name')",
循环:
var calcList1 = require('ui/common/convertd/calcs_db/calcs_models/outSort2').calcs_list;
var l = [];
var x = 0;
for (var i = 0; i < calcList1.length; i++) {
if (calcList1[i].z_clac_id == _args.z_dex) {
//>>>>this works>>>>>> Ti.API.info('>>', calcList1[i].z_param_name)
l.push = ( {
z_clac_id : calcList1[i].z_clac_id,
z_find : calcList1[i].z_find,
z_param_id : calcList1[i].z_param_id,
z_param_name : calcList1[i].z_param_name,
z_param_unit : calcList1[i].z_param_unit
});
}
};
Ti.API.info('>>>>>>>>>>>>>>>>>>>>>>>>>>', l[0].z_param_name);
答案 0 :(得分:3)
我认为你在这里不需要等号'=',但我不确定这是否是这里的主要问题:
l.push( {
z_clac_id : calcList1[i].z_clac_id,
z_find : calcList1[i].z_find,
z_param_id : calcList1[i].z_param_id,
z_param_name : calcList1[i].z_param_name,
z_param_unit : calcList1[i].z_param_unit
});