因为个人debug的不良方式,喜欢把this打印出来, 发现的问题
如下:很有可能是因为您没有 构造方法
class ImgFigure extends React.Component {
/*
*imgFigure的點擊處理函數
*/
handleClick(e){
console.log(this);
this.props.inverse();
e.stopPropagation();
e.preventDefault();
}
}
这种情况就写一个constructor把,es6之前叫做getInitial的方法
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
转载请注明原文地址: https://ju.6miu.com/read-39133.html