我提到ExtJS 5.01 dataview sample并在MVC架构中对其进行了修改。
但是浏览器显示错误消息有一个问题" Uncaught TypeError:无法读取属性' on' of null"。
我的代码有什么问题?
视口:
Ext.define('Fiddle.view.Viewport', {
extend: 'Ext.container.Viewport',
layout: 'border',
requires: [
'Fiddle.view.IconView'
],
items: [{
region: 'center',
xtype: 'iconview',
}]
});
商店:
Ext.define('Fiddle.store.IconView', {
extend: 'Ext.data.Store',
model: 'Fiddle.model.IconView',
data: [
{ src:'http://www.sencha.com/img/20110215-feat-drawing.png', caption:'Drawing & Charts' },
{ src:'http://www.sencha.com/img/20110215-feat-data.png', caption:'Advanced Data' },
{ src:'http://www.sencha.com/img/20110215-feat-html5.png', caption:'Overhauled Theme' },
{ src:'http://www.sencha.com/img/20110215-feat-perf.png', caption:'Performance Tuned' }
]
});
型号:
Ext.define('Fiddle.model.IconView', {
extend: 'Ext.data.Model',
fields: [
{ name:'src', type:'string' },
{ name:'caption', type:'string' }
]
});
查看:
Ext.define('Fiddle.view.IconView', {
extend: 'Ext.view.View',
alias: 'widget.iconview',
initComponent: function() {
var me = this;
var imageTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div style="margin-bottom: 10px;" class="thumb-wrap">',
'<img src="{src}" />',
'<br/><span>{caption}</span>',
'</div>',
'</tpl>'
);
Ext.apply(me, {
store: 'IconView',
itemSelector: 'div.thumb-wrap',
emptyText: 'No images available',
tpl: imageTpl
});
me.callParent(arguments);
}
});
答案 0 :(得分:1)