uploadImage(a){
.......
}
onPress={this.uploadImage.bind(this,this.state.avatarSource.uri)
上面这一段是可以的
constructor(props){
super(props);
this.uploadImage = this.uploadImage.bind(this);
}
onPress={this.uploadImage(this.state.avatarSource.uri)}
这么写就报错. 其他不带参数的事件这么写都正常, 这个带参数的哪里不对?
直接用箭头函数写 onPress={ ()=> this.uploadImage(this.state.avatarSource.uri)}