此代码用于打印操作键值:
result [
{ action: 'test' },
{ action: 'tests' },
{ action: 'tested' }
];
for (value = 0; value <= result.length; value ++) {
response = this.actions[value]['action'];
alert("Actions are: " + response);
}
但是,它会导致错误:action cannot be a read property
。
答案 0 :(得分:1)
代码中的操作未定义, 试试:
result = [ {action: 'test'},
{action: 'tests'},
{action: 'tested'} ];
for(value = 0; value <=result.length; value ++) {
response = this.result[value]['action'];
alert("Actions are: " +response); }