我有加载时从商店获得的数据,现在我想从菜单项中的arrayVals填充该数据...如果我在外部加载方法中调用me.items.push它可以正常工作数据,但当我在加载方法中调用它时,我收到错误,即对象[对象对象]没有方法'推送'
items = [];
var arrayVals = [];
me.getUserCompanyLogStore().load({
callback: function (records, operation, success) {
success: {
Ext.Array.each(records, function (record, index, array) {
arrayVals.push(record.get("company"));
});
Ext.Array.each(arrayVals, function (record, index, array) {
console.log(arrayVals)
me.items.push({ // Object [object Object] has no method 'push'
xtype: 'main-header-nav-FavoriteItem',
text: record
});
});
}
}
});
答案 0 :(得分:2)
您没有提供完整信息,但这是最有可能出现的情况:
到商店加载时,items
不再是一系列配置选项,因为容器已经处理过它们。相反,您需要调用me.add()
,因为项目现在是MixedCollection并且配置处理阶段已经过去。
答案 1 :(得分:0)
你可以这样试试:
var items = [];
var arrayVals = [];
var self = this;
me.getUserCompanyLogStore().load({
callback: function (records, operation, success) {
success: {
Ext.Array.each(records, function (record, index, array) {
arrayVals.push(record.get("company"));
});
Ext.Array.each(arrayVals, function (record, index, array) {
console.log(arrayVals)
self.items.push({ // Object [object Object] has no method 'push'
xtype: 'main-header-nav-FavoriteItem',
text: record
});
});
}
}
});