javascript 无法获取未定义或空引用的属性“id”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17876415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to get property 'id' of undefined or null reference
提问by Saravanan
I am trying to create a Ext.PagingToolbar, which works perfectly in all major browsers including IE9 and IE 10. But in IE 8and below, it ends up with the following error.
我正在尝试创建一个Ext.PagingToolbar,它可以在包括 IE9 和 IE 10 在内的所有主要浏览器中完美运行。但在IE 8及以下版本中,它最终会出现以下错误。
Unable to get property 'id' of undefined or null reference
无法获取未定义或空引用的属性“id”
When I traced, I found the error occurs in the following code.
当我跟踪时,我发现错误发生在以下代码中。
var cm = new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns:
[
{
header: 'Result Set',
dataIndex: 'result_set_name'
},
{
header: 'Result Date',
dataIndex: 'result_date',
xtype: 'datecolumn',
format: 'm/d/Y',
dateFormat: 'c'
},
{
header: 'Comments',
dataIndex: 'comments'
},
{
header: 'Link',
dataIndex: 'link',
renderer: function(value, metaData, record, rowIndex, colIndex, store) {return '<a href="'+value+'">'+value+'</a>';}
},
]
});
But I cannot find the source of issue and what need to be done. Any help is appreciated.
但是我找不到问题的根源以及需要做什么。任何帮助表示赞赏。
回答by sra
Your error is that you end the columns array with a comma which leads to such a error. The IE tries to read a object after the comma which will be undefined
你的错误是你用逗号结束了列数组,这会导致这样的错误。IE 尝试在逗号之后读取一个未定义的对象