【发布时间】:2019-03-01 11:51:29
【问题描述】:
我返回的错误是:order is undefined来自浏览器中的控制台
而 当我将 order 替换为 index 甚至是积分 (5) 之类的东西时,它工作得很好。 order 元素可能有什么问题?
提前致谢!
render() {
const { classes, index, color, order, onClick } = this.props;
return (
<div
className={ClassNames({
[classes.general]: true,
[classes.borderBlack]: true,
position:'relative'
})}
style={{ backgroundColor: color }}
onMouseOver={this.mouseOver.bind(this)}
onMouseLeave={this.mouseOut.bind(this)}
//----Makes markers clickable
onClick={onClick}
>
{index}
{this.state.hover ? <div style={{
color: 'white',
position:'absolute',
fontSize:30,
backgroundColor: 'black'
}}>{order}</div> : null}
</div>
);
}
【问题讨论】:
-
你有控制台记录 this.props 吗?
-
What could possibly be wrong with the order element?props 中没有定义。 -
如果 this.props 中存在订单,那么它应该被破坏。通过 console.log 检查 this.props
标签: javascript reactjs element