-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v1.1更新说明 #3
Comments
关于:修改了闭包传递方法的写法 之前 /**
* 利用rearrange函数居中对应index的图片
* @param index 需要被居中的图片的索引值
* return {function}
*/
center(index){
return () => this.rearrange(index);
}
/**
* 翻转图片
* @param index 传入当前被执行inverse操作的图片对应的图片信息数组的index值
* @returns {Function} 这是一个闭包函数, 其内return一个真正待被执行的函数
*/
inverse(index){
return () => {
let imgsArrangeArr = this.state.imgsArrangeArr;
imgsArrangeArr[index].isInverse = !imgsArrangeArr[index].isInverse;
this.setState({
imgsArrangeArr: imgsArrangeArr
});
}
}
// ....
let commonProps = {
key: index,
arrange: this.state.imgsArrangeArr[index],
inverse: this.inverse(index),
center: this.center(index)
};
imgFigure.push( <ImgFigure data={value} ref={'imgFigure' + index} {...commonProps}/> );
cotrollerUnits.push( <ControllerUnit {...commonProps} />); 修改之后 /**
* 利用rearrange函数居中对应index的图片
* @param index 需要被居中的图片的索引值
* return {function}
*/
center(index){
this.rearrange(index);
}
/**
* 翻转图片
* @param index 传入当前被执行inverse操作的图片对应的图片信息数组的index值
* @returns {Function} 这是一个闭包函数, 其内return一个真正待被执行的函数
*/
inverse(index) {
let imgsArrangeArr = this.state.imgsArrangeArr;
imgsArrangeArr[index].isInverse = !imgsArrangeArr[index].isInverse;
this.setState({
imgsArrangeArr: imgsArrangeArr
});
}
//....
let commonProps = {
key: index,
arrange: this.state.imgsArrangeArr[index],
inverse: this.inverse.bind(this,index),
center: this.center.bind(this,index)
};
imgFigure.push( <ImgFigure data={value} ref={'imgFigure' + index} {...commonProps}/> );
cotrollerUnits.push( <ControllerUnit {...commonProps} />); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v1.1更新说明
The text was updated successfully, but these errors were encountered: