ext开发中火狐浏览器不报错,但是到IE浏览器中报'events'为空或不是对象,由于IE不能用firebug捕捉错误,当代码量很大时用alert()很难找到,只能一点一点的删除代码测试。
当IE中报这个错误时多数为items中最后一项多了个逗号:
如:
Ext.onReady(function(){ new Ext.Panel({ renderTo:"hello", tltie:"容器组件", width:500, height:200, layout:"accordion", layoutConfig:{ animate:true }, items:[{title:"子元素1",html:"这是子元素1的内容"}, {title:"子元素2",html:"这是子元素2的内容"}, {title:"子元素3",html:"这是子元素3的内容"}, ] }); });
items中最后一项
{title:"子元素3",html:"这是子元素3的内容"},
的逗号去掉就OK了
2.'render'为空或不是对象
此错误也是只在IE中出现在火狐中不出现,同样此错误也是因为多了逗号引起的,不过是多在button中而已:
Ext.onReady(function(){ new Ext.Panel({ renderTo:"hello", tltie:"容器组件", width:500, height:200, layout:"accordion", layoutConfig:{ animate:true }, items:[{title:"子元素1",html:"这是子元素1的内容"} ] , buttons : [ {text : "保存", iconCls : 'saveIconCss', handler :function(){ this.save; }, scope : this}, {text : "关闭", iconCls : 'closeIconCss', handler :this.closeWin, scope : this}, ] }); });
将buttons中的最后一项
{text : "关闭", iconCls : 'closeIconCss', handler :this.closeWin, scope : this},
的逗号去掉就可以了