我有这段代码,我正在尝试使用'_currentModel'对象访问'model'数组。
// an array I want to access
var model = [
{
name:'haha',
image:'cat1.jpg',
count: 0
},
{
name: 'pew',
image: 'cat2.jpg',
count: 0
},
{
name: 'wow',
image: 'cat3.jpg',
count: 0
}
];
应该访问它的对象
var _currentModel = {
index: 0,
name: model[this.index].name, //error: model[this.index] is undefined
image: model[_currentModel.index].image, //error: _currentModel is undefined
count: model[_currentModel.index].count //error: _currentModel is undefined
}