中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
实时验证手机号Button的实现
微信扫码分享
// GetRealtimePhoneNumber.ets import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; @Entry @Component struct Index { build() { Row() { Column() { // 声明FunctionalButton FunctionalButton({ params: { // OpenType.GET_REALTIME_PHONENUMBER表示Button为实时验证手机号类型 openType: functionalButtonComponentManager.OpenType.GET_REALTIME_PHONENUMBER, label: '实时验证手机号', // 调整Button样式 styleOption: { styleConfig: new functionalButtonComponentManager.ButtonConfig() .fontSize(20) .fontColor(Color.Black) } }, // OpenType为“GET_REALTIME_PHONENUMBER”时,回调必须选择“onGetRealtimePhoneNumber” controller: new functionalButtonComponentManager.FunctionalButtonController() .onGetRealtimePhoneNumber((err, data) => { if (err) { // 错误日志处理 hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message); return; } // 成功日志处理 hilog.info(0x0000, "testTag", "succeeded in authenticating"); // 获取AuthorizationCode let authorizationCode = data.code; }) }) } .width('100%') } .height('100%') } }