未捕获的类型错误和已修复的数据表
Uncaught TypeError and Fixed Data Table
我尝试用这段代码运行固定数据表。
var MyCompi=React.createClass({
getInitialState: function() {
return{ rows : [{"id":1,"first_name":"William","last_name":"Elliott","email":"welliott0@wisc.edu",
"country":"Argentina","ip_address":"247.180.226.89"},
{"id":2,"first_name":"Carl","last_name":"Ross","email":"cross1@mlb.com",
"country":"South Africa","ip_address":"27.146.70.36"},
{"id":3,"first_name":"Jeremy","last_name":"Scott","email":"jscott2@cbsnews.com",
"country":"Colombia","ip_address":"103.52.74.225"}] };
},
render:function(){
return(
<Table
height={this.state.rows.length * 300}
width={1150}
rowsCount={this.state.rows.length}
rowHeight={30}
headerHeight={30}
rowGetter={function(rowIndex) {return this.state.rows[rowIndex]; }}>
<Column dataKey="id" width={50} label="Id" />
<Column dataKey="first_name" width={200} label="First Name" />
<Column dataKey="last_name" width={200} label="Last Name" />
</Table>
);
}
});
ReactDOM.render(<MyCompi/>
,
document.getElementById('root')
);
但我犯了错误。
- Uncaught TypeError:无法读取未定义的属性"rows"
当我像"rows[]"那样设置getInitialState(rows)时,异常就会消失。但在这种情况下,我得到了空的数据表。
我真的对此感到困惑。有什么帮助吗?
在rowGetter
函数中,this
不引用组件。您可以使用箭头功能:
rowGetter={rowIndex => this.state.rows[rowIndex]}
了解有关this
和此问题的更多信息:如何在回调中访问正确的"this"上下文?
相关文章:
- 谷歌图表 - 地理图表“不兼容的数据表:错误:未知地址类型
- 数据表未捕获类型错误
- 数据表错误 - 无法读取未定义的属性“长度”
- jquery数据表显示/隐藏列添加了错误的选择
- 不兼容的数据表: 错误:表包含的列数超过预期
- 使用 JS 填充 HTML 表,数据顺序错误
- 谷歌图表绘制()方法错误类型时给定数据表
- 数据表:未捕获类型错误:无法读取未定义的属性“按钮”
- 无法读取数据表中未定义错误的属性“长度”.js
- 尝试在 ASP.Net 中使用 jquery 数据表时出现 Jscript 运行时错误
- 未捕获的类型错误和已修复的数据表
- 绑定jquery数据表给出错误“”;请求的未知参数'0'来自行0”的数据源;
- js数据表重新排列后排序错误
- 在Spring MVC中字符串显示YUI数据表时发生数据错误
- c# /数据表错误使用JsonWriter:无效的JSON原语:draw
- jQuery数据表错误- TypeError: Cannot read property '的定义
- 数据表错误'执行appendChild()失败'
- 如何使用ColumnFilter或LightColumnFilter与角数据表错误b.dataTable.columnF
- 数据表错误::无法读取属性'fnSetData'的未定义
- Jquery 数据表错误:未捕获类型错误:无法读取未定义的属性“0”