我试图从商店获取图像,并控制图像的数量,并为每个轮播显示 12 张图像,所有这些都取决于商店中的图像数量,如果它达到前:12,则创建一个其余的其他轮播......但我试图从商店中获取图像并将其加载到轮播开始,但我的视图是空的,没有任何显示..
该模型 :
Ext.define("MyApp2.model.ApplicationModel", {
extend: "Ext.data.Model",
config: {
//type:'tree',
fields: [
{name: 'id', type: 'auto'},
{name: 'name', type: 'auto'},
{name:'icon',type:'image/jpg'}
]
}
});
商店:
var token=localStorage.getItem("access_token");
Ext.define("MyApp2.store.ApplicationStore", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.JsonP"],
config: {
model: "MyApp2.model.ApplicationModel",
autoLoad: true,
id :'ApplicationStr',
proxy: {
type: 'jsonp',
url: 'http://mysite.com/api/applications?format=jsonp&access_token='+token,
reader: {
type: 'json',
rootProperty: 'applications'
}
}
}
});
var store = Ext.create('MyApp2.store.ApplicationStore');
store.getStore('ApplicationStr');
myCarousel = Ext.getCmp('carouselid');
store.each(function(record) {
myCarousel.add({
html: '<img src=' + record.get('icon') + '/>'
});
});
风景 :
Ext.define('MyApp2.view.MainMenu', {
extend: 'Ext.Panel',
requires: ['Ext.TitleBar', 'MyApp2.store.ApplicationStore', 'Ext.dataview.List', 'Ext.Img'],
alias: 'widget.mainmenuview',
config: {
layout: {
type: 'fit'
},
items: [{
xtype: 'titlebar',
title: 'My Apps',
docked: 'top',
items: [
{
xtype: 'button',
text: 'Log Off',
itemId: 'logOffButton',
align: 'right'
}
]
},
{
xtype: "carousel",
id: 'carouselid'
}
],
listeners: [{
delegate: '#logOffButton',
event: 'tap',
fn: 'onLogOffButtonTap'
}]
},
onLogOffButtonTap: function() {
this.fireEvent('onSignOffCommand');
}
});