我正在尝试将“this”绑定到google firebase函数,但我无法在promise中获得此值。请检查下面的代码。
this.props.getUser.linkWithCredential(y)
.then((response) => {
***this.props.history.replace('/');***
}).catch((error) => {
switch (error.code) {
case 'auth/provider-already-linked':
this.setState({formError: 'already been linked to the user'});
break;
case 'auth/invalid-credential':
this.setState({formError: '(otp-03) Please contact customer service for more details.'});
break;
case 'auth/credential-already-in-use':
this.setState({formError: 'Mobile number is already linked with another account. Please contact customer service for more details.'});
break;
case 'auth/invalid-verification-code':
this.setState({formError: 'OTP code is wrong, Please enter the correct code.'});
break;
case 'auth/invalid-verification-id':
this.setState({formError: '(otp-04) Please contact customer service for more details.'});
break;
default:
this.setState({formError: '(otp-05) Please contact customer service for more details.'});
}
})
所以当调用时(this.props.history.replace('/');)我对“这个”乳清无法发现我无法访问它?我怎么能在这里使用bind?