在放大验证器注册组件中设置默认国家代码
Set default country code in amplify authenticator signup component
Amplify authenticator 真的很方便普通的认证流程。
默认情况下,国家代码是前select到+1,但为其他国家开发的应用程序可能希望默认为另一个。
有没有办法更改selected 前的默认值。
The official document 不包含任何关于此的内容。
signUpConfig.defaultCountryCode 救援。
看完amplify-js的源码。代码在这里。
getDefaultDialCode() {
return this.props.signUpConfig &&
this.props.signUpConfig.defaultCountryCode &&
countryDialCodes.indexOf(
`+${this.props.signUpConfig.defaultCountryCode}`
) !== -1
? `+${this.props.signUpConfig.defaultCountryCode}`
: '+1';
}
所以要用它。 HOC 应该喜欢
export default withAuthenticator(App, {signUpConfig: {defaultCountryCode: 61}})
您可以在 formFields 中传递 dialCode
。
{
type: 'phone_number',
dialCode: 27, // or '+27'
value: '5555555555',
}
Amplify authenticator 真的很方便普通的认证流程。
默认情况下,国家代码是前select到+1,但为其他国家开发的应用程序可能希望默认为另一个。
有没有办法更改selected 前的默认值。
The official document 不包含任何关于此的内容。
signUpConfig.defaultCountryCode 救援。
看完amplify-js的源码。代码在这里。
getDefaultDialCode() {
return this.props.signUpConfig &&
this.props.signUpConfig.defaultCountryCode &&
countryDialCodes.indexOf(
`+${this.props.signUpConfig.defaultCountryCode}`
) !== -1
? `+${this.props.signUpConfig.defaultCountryCode}`
: '+1';
}
所以要用它。 HOC 应该喜欢
export default withAuthenticator(App, {signUpConfig: {defaultCountryCode: 61}})
您可以在 formFields 中传递 dialCode
。
{
type: 'phone_number',
dialCode: 27, // or '+27'
value: '5555555555',
}