文档管理中心
您当前浏览的HarmonyOS 5.0.1(API 13)文档归档不再维护,推荐您使用最新版本。详细请参考文档维护策略变更
API参考应用服务Scenario Fusion Kit(融合场景服务)ArkTS组件functionalButtonComponentManager(场景化融合Button组件管理)

functionalButtonComponentManager(场景化融合Button组件管理)

本模块提供Button组件的逻辑管理,辅助HarmonyOS应用和元服务通过Button组件完成相应功能。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

导入模块

收起
自动换行
深色代码主题
复制
  1. import { functionalButtonComponentManager } from '@kit.ScenarioFusionKit';

OpenType

该枚举定义了FunctionalButton组件的功能类型,通过设置该参数来指定FunctionalButton的功能。

模型约束:此接口仅可在Stage模型下使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

说明

GET_PHONE_NUMBER

0

快速验证手机号。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

GET_REALTIME_PHONENUMBER

1

实时验证手机号。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

说明

GET_REALTIME_PHONENUMBER暂不对外开放使用。

LAUNCH_APP

2

打开APP。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

OPEN_SETTING

3

打开授权设置页。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

CHOOSE_AVATAR

4

选择头像。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

CHOOSE_ADDRESS

5

选择地址。

起始版本:5.0.0(12)

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

CHOOSE_INVOICE_TITLE

6

选择发票抬头。

起始版本:5.0.0(12)

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

REAL_NAME_AUTHENTICATION

7

实名信息校验。

起始版本:5.0.0(12)

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

说明

REAL_NAME_AUTHENTICATION暂不对外开放使用。

FACE_AUTHENTICATION

8

人脸核身。

起始版本:5.0.0(12)

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

说明

FACE_AUTHENTICATION暂不对外开放使用。

CHOOSE_LOCATION

9

地图选点。

起始版本:5.0.0(12)

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

SUBSCRIBE_LIVE_VIEW

10

实况窗订阅。

起始版本:5.0.0(12)

SizeType

该枚举定义了FunctionalButton的尺寸类型。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

说明

DEFAULT

0

默认大小。

MINI

1

小尺寸。

HoverClassType

该枚举定义了FunctionalButton点击态的类型。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

说明

NONE

0

无效果。

HOVER_CLASS

1

默认样式。

ColorType

该枚举定义了FunctionalButton的颜色类型。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

说明

DEFAULT

0

蓝色。

PRIMARY

1

绿色。

WARN

2

红色。

CredentialType

该枚举定义了FunctionalButton的认证类型。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

说明

IDCard

0

身份证件类型。

RealNameAuthenticationInfo

该接口定义了FunctionalButton组件的实名信息校验(预留能力,暂未支持)。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

openID

string

OpenID是华为账号用户在不同类型的产品的身份ID,同一个用户,不同应用,OpenID值不同。

realName

string

证件姓名。

credentialID

Uint8Array

证件号码。

credentialType

CredentialType

证件类型。

StyleOption

该接口定义了FunctionalButton组件的样式信息。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

size

SizeType

按钮尺寸类型。默认值:functionalButtonComponentManager.SizeType.DEFAULT,字体大小为:16fp。

bgColor

ColorType

按钮颜色类型。默认值:functionalButtonComponentManager.ColorType.DEFAULT,默认蓝底白字按钮样式。

plain

boolean

按钮是否镂空。“true”表示镂空。默认值:false,不镂空。

disabled

boolean

按钮是否禁用。“true”表示按钮禁用。默认值:false,不禁用Button。

loading

boolean

名称前是否带loading图标。“true”表示名称前带loading图标。

默认值:false,关闭loading动画。

hoverClass

HoverClassType

按钮按下去的样式。默认值:functionalButtonComponentManager.HoverClassType.HOVER_CLASS,开启点击效果。

hoverStartTime

number

按住后多久出现点击态,单位毫秒。

默认值:0

取值范围: [0, +∞)

说明

设置为小于0的值时,按值为0处理。

hoverStayTime

number

手指松开后点击态保留时间,单位毫秒。

默认值:0

取值范围: [0, +∞)

说明

设置为小于0的值时,按值为0处理。

styleConfig

ButtonConfig

按钮样式配置。

说明

当styleConfig和StyleOption中定义的样式冲突时,最终以styleConfig的为准。

FunctionalButtonParams

该接口定义了FunctionalButton组件的参数,定义Button功能以及样式等。

模型约束:此接口仅可在Stage模型下使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

openType

OpenType

按钮功能场景类型。默认值:functionalButtonComponentManager.OpenType.GET_PHONE_NUMBER。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

label

ResourceStr

按钮展示文字。默认值:空字符串。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

styleOption

StyleOption

按钮样式。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

说明

在Button外设置的样式属性不生效,仅生效styleOption中设置的样式。

appParam

AppParam

需打开APP的信息。例如:{bundleName: "xxx", abilityName: "xxx"}。

bundleName:包名。

abilityName:Ability名称。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

说明

openType为“functionalButtonComponentManager.OpenType.LAUNCH_APP”时必填。

realNameAuthenticationInfo

RealNameAuthenticationInfo

实名信息校验按钮信息(预留能力,暂未支持)。

起始版本:5.0.0(12)

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

subscribeLiveViewParam

SubscribeLiveViewParam

实况窗订阅按钮信息。

起始版本:5.0.0(12)

GetPhoneNumberResult

该接口定义了使用快速验证功能成功验证的响应。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

code

string

账号用户的临时登录凭证(Authorization Code)。

说明

可通过临时登录凭证获取真实手机号,临时登录凭证时效5分钟,具体操作可参考“服务端开发”章节。

GetRealtimePhoneNumberResult

该接口定义了使用实时验证功能成功验证的响应。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

code

string

账号用户的临时登录凭证(Authorization Code)。

说明

可通过临时登录凭证获取真实手机号,临时登录凭证时效5分钟,具体操作可参考“服务端开发”章节。

OpenSettingResult

该接口定义了使用打开授权设置页功能,成功跳转授权设置页后返回应用或结束设置应用,应用权限设置情况的响应。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

permissions

Map<string, boolean>

权限字典表。

key为权限名称,value为权限是否开启,true表示开启权限,false表示关闭权限。

ChooseAvatarResult

该接口定义了使用选择头像功能成功选择的响应。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

avatarUri

string

所选头像图片的地址。

说明

返回的地址为裁剪之后的图片对应的地址。

AppParam

该接口定义了FunctionalButton为打开APP功能时,通过该参数指定打开的应用对应的包名和Ability名称。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

展开

名称

类型

只读

可选

说明

bundleName

ResourceStr

包名。

abilityName

ResourceStr

Ability名称。默认值:EntryAbility。

ChooseAddressResult

该接口定义了FunctionalButton为选择收货地址功能时,通过该参数指定选择收货地址对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

userName

string

用户名称。

mobileNumber

string

手机号码。

telNumber

string

固定电话号码。

zipCode

string

邮政编码。

countryCode

string

国家/地区代码。

provinceName

string

省份名称。

cityName

string

城市名称。

districtName

string

地区名称。

streetName

string

街道名称。

detailedAddress

string

详细地址。

ChooseInvoiceTitleResult

该接口定义了FunctionalButton为选择发票抬头功能时,通过该参数指定选择发票抬头对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

type

string

发票类型,0-个人 1-企业。

title

string

发票抬头。

taxNumber

string

税号。

companyAddress

string

公司地址。

telephone

string

电话号码。

bankName

string

银行名称。

bankAccount

string

银行账户。

RealNameAuthenticationResult

该接口定义了FunctionalButton为实名信息校验功能时,通过该参数指定实名信息校验对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

authCode

string

临时凭据,有效时间5分钟,并且只能使用一次。

openID

string

OpenID是华为账号用户在不同类型的产品的身份ID,同一个用户,不同应用,OpenID值不同。

FaceAuthenticationResult

该接口定义了FunctionalButton为人脸核身功能时,通过该参数指定人脸认证对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

authCode

string

临时凭据,有效时间5分钟,并且只能使用一次。

openID

string

OpenID是华为账号用户在不同类型的产品的身份ID,同一个用户,不同应用,OpenID值不同。

FaceVerificationResult

该接口定义了FunctionalButton为人脸核身功能时,通过该参数指定人脸核身对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

facialRecognitionVerificationToken

string

验证成功后返回的token。

state

string

响应体中返回的state,字符包含0-9、a-z、A-Z、英文点号、英文冒号、斜杆、下划线等,长度限制255,校验规则^[0-9a-zA-Z:/\.\-_]{1,255}$。与请求体中传入的state比较,校验是否是当前请求,防止跨站攻击。

ChooseLocationResult

该接口定义了FunctionalButton为地图选点功能时,通过该参数指定地图选点对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

name

string

位置名称。

longitude

number

经度。

latitude

number

纬度。

address

string

地址。

SubscribeLiveViewParam

该接口定义了FunctionalButton组件为实况窗订阅功能时,通过该参数指定实况窗订阅对应的订阅事件和计时器。

模型约束:此接口仅可在Stage模型下使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

event

string

订阅事件。

固定值:SUBSCRIBE_TIMER。

alertTime

number

计时器提醒时间,毫秒级时间戳。

说明
  1. 参数不能为空。
  2. 0<=startTime-alertTime。
  3. startTime和alertTime晚于当前时间。
  4. startTime-alertTime <= 3600000(可在push侧配置)。

startTime

number

计时器开始时间,毫秒级时间戳。

说明
  1. 参数不能为空。
  2. 0<=startTime-alertTime。
  3. startTime和alertTime晚于当前时间。
  4. startTime-alertTime <= 3600000(可在push侧配置)。

SubscribeLiveViewResult

该接口定义了FunctionalButton组件为实况窗订阅功能时,通过该参数指定实况窗订阅对应的返回体。

模型约束:此接口仅可在Stage模型下使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

展开

名称

类型

只读

可选

说明

subscribeId

string

订阅事件ID。

事件

不支持通用事件,仅支持以下事件:

FunctionalButtonController

FunctionalButton组件控制器,用来回调组件内部的点击事件。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

onGetPhoneNumber

onGetPhoneNumber(callback: AsyncCallback<GetPhoneNumberResult>): FunctionalButtonController

注册FunctionalButton组件为快速验证手机号的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<GetPhoneNumberResult>

回调函数。callback返回账号用户的临时登录凭证(Authorization Code)。

说明

可通过临时登录凭证获取真实手机号,临时登录凭证时效5分钟,具体操作可参考“服务端开发”章节。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.GET_PHONE_NUMBER表示Button为快速验证手机号类型
  13. openType: functionalButtonComponentManager.OpenType.GET_PHONE_NUMBER,
  14. label: '快速验证手机号',
  15. // 调整Button样式
  16. styleOption: {
  17. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  18. .fontSize(20)
  19. .fontColor(Color.Black)
  20. },
  21. },
  22. // OpenType为“GET_PHONE_NUMBER”时,回调必须选择“onGetPhoneNumber”
  23. controller: new functionalButtonComponentManager.FunctionalButtonController()
  24. .onGetPhoneNumber((err, data) => {
  25. if (err) {
  26. // 错误日志处理
  27. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  28. return;
  29. }
  30. // 成功日志处理
  31. hilog.info(0x0000, "testTag", "succeeded in authenticating");
  32. // 获取Authorization Code
  33. let authorizationCode = data.code;
  34. })
  35. })
  36. }.width('100%')
  37. }.height('100%')
  38. }
  39. }

onGetRealtimePhoneNumber

onGetRealtimePhoneNumber(callback: AsyncCallback<GetRealtimePhoneNumberResult>): FunctionalButtonController

注册FunctionalButton组件为实时验证手机号的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<GetRealtimePhoneNumberResult>

回调函数。callback返回账号用户的临时登录凭证(Authorization Code)。

说明

可通过临时登录凭证获取真实手机号,临时登录凭证时效5分钟,具体操作可参考“服务端开发”章节。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import {FunctionalButton, functionalButtonComponentManager} from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.GET_REALTIME_PHONENUMBER表示Button为实时验证手机号类型
  13. openType: functionalButtonComponentManager.OpenType.GET_REALTIME_PHONENUMBER,
  14. label: '实时验证手机号',
  15. // 调整Button样式
  16. styleOption: {
  17. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  18. .fontSize(20)
  19. .fontColor(Color.Black)
  20. },
  21. },
  22. // OpenType为“GET_REALTIME_PHONENUMBER”时,回调必须选择“onGetRealtimePhoneNumber”
  23. controller: new functionalButtonComponentManager.FunctionalButtonController()
  24. .onGetRealtimePhoneNumber((err, data) => {
  25. if (err) {
  26. // 错误日志处理
  27. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  28. return;
  29. }
  30. // 成功日志处理
  31. hilog.info(0x0000, "testTag", "succeeded in authenticating");
  32. // 获取Authorization Code
  33. let authorizationCode = data.code;
  34. })
  35. })
  36. }
  37. .width('100%')
  38. }
  39. .height('100%')
  40. }
  41. }

onLaunchApp

onLaunchApp(callback: AsyncCallback<void>): FunctionalButtonController

注册FunctionalButton组件为打开APP的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<void>

回调函数。当打开APP完成,err为undefined,否则返回错误对象。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.LAUNCH_APP表示Button为打开APP类型
  13. openType: functionalButtonComponentManager.OpenType.LAUNCH_APP,
  14. label: '打开APP',
  15. // OpenType为“functionalButtonComponentManager.OpenType.LAUNCH_APP”时,appParam参数必填
  16. appParam: {
  17. bundleName: "xxx",
  18. abilityName: "xxx"
  19. },
  20. // 调整Button样式
  21. styleOption: {
  22. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  23. .fontSize(20)
  24. .fontColor(Color.Black)
  25. },
  26. },
  27. // OpenType为“LAUNCH_APP”时,回调必须选择“onLaunchApp”
  28. controller: new functionalButtonComponentManager.FunctionalButtonController().onLaunchApp((err) => {
  29. if (err) {
  30. // 错误日志处理
  31. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  32. return;
  33. }
  34. // 成功日志处理,成功时无返回值
  35. hilog.info(0x0000, "testTag", "succeeded in launching app");
  36. })
  37. })
  38. }.width('100%')
  39. }.height('100%')
  40. }
  41. }
说明

“bundleName”为包名,“abilityName”为Ability名称。

onOpenSetting

onOpenSetting(callback: AsyncCallback<OpenSettingResult>): FunctionalButtonController

注册FunctionalButton组件为打开授权设置页的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<OpenSettingResult>

回调函数。callback会返回跳转失败时的错误码,当成功跳转授权设置页后,返回应用或结束设置应用返回权限设置情况。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.OPEN_SETTING表示Button为打开授权设置页类型
  13. openType: functionalButtonComponentManager.OpenType.OPEN_SETTING,
  14. label: '打开授权设置页',
  15. // 调整Button样式
  16. styleOption: {
  17. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  18. .fontSize(20)
  19. .fontColor(Color.Black)
  20. },
  21. },
  22. // OpenType为“OPEN_SETTING”时,回调必须选择“onOpenSetting”
  23. controller: new functionalButtonComponentManager.FunctionalButtonController().onOpenSetting((err, data) => {
  24. if (err) {
  25. // 错误日志处理
  26. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  27. return;
  28. }
  29. // 成功日志处理,终止设置应用程序时触发
  30. hilog.info(0x0000, "testTag", "succeeded in opening setting");
  31. data.permissions!.forEach((value, key) => {
  32. hilog.info(0x0000, "testTag", "key: %{public}s value: %{public}s", String(key), value);
  33. })
  34. })
  35. })
  36. }.width('100%')
  37. }.height('100%')
  38. }
  39. }

onChooseAvatar

onChooseAvatar(callback: AsyncCallback<ChooseAvatarResult>): FunctionalButtonController

注册FunctionalButton组件为选择头像的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<ChooseAvatarResult>

回调函数。callback返回所选头像图片的地址。

说明

返回的地址为裁剪之后的图片对应的地址。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. // 对应路径 /resources/base/media/下新增 account.png,否则会报错找不到
  7. @State url: ResourceStr = $r('app.media.account');
  8. build() {
  9. Column() {
  10. // 声明FunctionalButton
  11. FunctionalButton({
  12. params: {
  13. // OpenType.CHOOSE_AVATAR表示Button为选择头像类型
  14. openType: functionalButtonComponentManager.OpenType.CHOOSE_AVATAR,
  15. label: '',
  16. // 调整Button样式
  17. styleOption: {
  18. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  19. .type(ButtonType.Normal)
  20. .backgroundImage(this.url)
  21. .backgroundImageSize(ImageSize.Cover)
  22. .width(80)
  23. .height(80)
  24. .backgroundColor('#E5E5E5')
  25. },
  26. },
  27. // OpenType为“CHOOSE_AVATAR”时,回调必须选择“onChooseAvatar”
  28. controller: new functionalButtonComponentManager.FunctionalButtonController().onChooseAvatar((err, data) => {
  29. if (err) {
  30. // 错误日志处理
  31. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  32. return;
  33. }
  34. // 成功日志处理
  35. hilog.info(0x0000, "testTag", "succeeded in choosing avatar");
  36. this.url = data.avatarUri!;
  37. })
  38. })
  39. }
  40. .padding({ top: 200 })
  41. .height('100%')
  42. .width('100%')
  43. }
  44. }

onChooseAddress

onChooseAddress(callback: AsyncCallback<ChooseAddressResult>): FunctionalButtonController

注册FunctionalButton组件为选择收货地址的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<ChooseAddressResult>

回调函数。callback返回选择收货地址的地址。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:
收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.CHOOSE_ADDRESS表示Button为选择收货地址
  13. openType: functionalButtonComponentManager.OpenType.CHOOSE_ADDRESS,
  14. label: '选择收货地址',
  15. // 调整Button样式
  16. styleOption: {
  17. bgColor:functionalButtonComponentManager.ColorType.DEFAULT,
  18. size: functionalButtonComponentManager.SizeType.DEFAULT,
  19. plain: false,
  20. disabled:false,
  21. loading: false,
  22. hoverClass: functionalButtonComponentManager.HoverClassType.HOVER_CLASS,
  23. hoverStartTime: 0,
  24. hoverStayTime: 0,
  25. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  26. .fontSize(20)
  27. .fontColor(Color.Black)
  28. },
  29. },
  30. // OpenType为“CHOOSE_ADDRESS”时,回调必须选择“onChooseAddress”
  31. controller: new functionalButtonComponentManager.FunctionalButtonController()
  32. .onChooseAddress((err, data) => {
  33. if (err) {
  34. // 错误日志处理
  35. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  36. return;
  37. }
  38. // 成功日志处理
  39. hilog.info(0x0000, "testTag", "succeeded in choosing address");
  40. // 获取Address info
  41. let userName: string = data.userName;
  42. let mobileNumber: string = data.mobileNumber as string;
  43. let countryCode: string = data.countryCode as string;
  44. let provinceName: string = data.provinceName as string;
  45. let cityName: string = data.cityName as string;
  46. let districtName: string = data.districtName as string;
  47. let streetName: string = data.streetName as string;
  48. let detailedAddress: string = data.detailedAddress;
  49. })
  50. })
  51. }.width('100%')
  52. }.height('100%')
  53. }
  54. }

onChooseInvoiceTitle

onChooseInvoiceTitle(callback: AsyncCallback<ChooseInvoiceTitleResult>): FunctionalButtonController

注册FunctionalButton组件为选择发票抬头的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<ChooseInvoiceTitleResult>

回调函数。callback返回选择发票抬头的结果。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.CHOOSE_INVOICE_TITLE表示Button为选择发票抬头
  13. openType: functionalButtonComponentManager.OpenType.CHOOSE_INVOICE_TITLE,
  14. label: '选择发票抬头',
  15. // 调整Button样式
  16. styleOption: {
  17. bgColor:functionalButtonComponentManager.ColorType.DEFAULT,
  18. size: functionalButtonComponentManager.SizeType.DEFAULT,
  19. plain: false,
  20. disabled:false,
  21. loading: false,
  22. hoverClass: functionalButtonComponentManager.HoverClassType.HOVER_CLASS,
  23. hoverStartTime: 0,
  24. hoverStayTime: 0,
  25. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  26. .fontSize(20)
  27. .fontColor(Color.Black)
  28. },
  29. },
  30. // OpenType为“CHOOSE_INVOICE_TITLE”时,回调必须选择“onChooseInvoiceTitle”
  31. controller: new functionalButtonComponentManager.FunctionalButtonController()
  32. .onChooseInvoiceTitle((err, data) => {
  33. if (err) {
  34. // 错误日志处理
  35. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  36. return;
  37. }
  38. // 成功日志处理
  39. hilog.info(0x0000, "testTag", "succeeded in obtaining invoice title");
  40. // 获取发票信息
  41. let type: string = data.type;
  42. let title: string = data.title;
  43. let taxNumber: string = data.taxNumber;
  44. let companyAddress: string | undefined = data.companyAddress;
  45. let telephone: string | undefined = data.telephone;
  46. let bankName: string | undefined = data.bankName;
  47. let bankAccount: string | undefined = data.bankAccount;
  48. })
  49. })
  50. }.width('100%')
  51. }.height('100%')
  52. }
  53. }

onRealNameAuthentication

onRealNameAuthentication(callback: AsyncCallback<RealNameAuthenticationResult>): FunctionalButtonController

注册FunctionalButton组件为实名信息校验的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<RealNameAuthenticationResult>

回调函数。callback返回实名信息校验鉴权对应的返回体:authCode、openID。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import { http } from '@kit.NetworkKit';
  4. import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
  5. interface Result {
  6. state?: number;
  7. realNameLevel?: number;
  8. verifyResult?: number;
  9. verifyToken?: string;
  10. }
  11. @Entry
  12. @Component
  13. struct SecondPage {
  14. obtainRealNameDataInfo(authCode: string, sceneID:number, openID: string, realName: string, idNo: string,
  15. callback: AsyncCallback<Result>) {
  16. // 每一个httpRequest对应一个HTTP请求任务,不可复用
  17. let httpRequest = http.createHttp();
  18. // 用于订阅HTTP响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息
  19. httpRequest.on('headersReceive', (header) => {
  20. hilog.info(0x0000, "testTag", "header: %{public}s", header as string);
  21. });
  22. httpRequest.request(
  23. // 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定
  24. "EXAMPLE_URL",
  25. {
  26. method: http.RequestMethod.POST,
  27. // 开发者根据自身业务需要添加header字段
  28. header: {
  29. 'Content-Type': 'application/json'
  30. },
  31. // 当使用POST请求时此字段用于传递内容
  32. extraData: {
  33. "authCode": authCode,
  34. "sceneID": sceneID,
  35. "openID": openID,
  36. "realname": realName,
  37. "idNo": idNo,
  38. },
  39. expectDataType: http.HttpDataType.STRING,
  40. usingCache: true,
  41. priority: 1,
  42. connectTimeout: 60000,
  43. readTimeout: 60000,
  44. usingProtocol: http.HttpProtocol.HTTP1_1,
  45. }, (err, data) => {
  46. if (!err) {
  47. let res: Result = JSON.parse(data.result as string);
  48. callback(undefined, res);
  49. } else {
  50. let error: BusinessError = {code: err.code, message: err.message, name: ''};
  51. callback(error, undefined);
  52. // 取消订阅HTTP响应头事件
  53. httpRequest.off('headersReceive');
  54. // 当该请求使用完毕时,调用destroy方法主动销毁
  55. httpRequest.destroy();
  56. }
  57. })
  58. }
  59. build() {
  60. Row() {
  61. Column() {
  62. FunctionalButton({
  63. params: {
  64. // OpenType.REAL_NAME_AUTHENTICATION表示Button为实名信息校验
  65. openType: functionalButtonComponentManager.OpenType.REAL_NAME_AUTHENTICATION,
  66. label: '实名信息校验',
  67. // 调整Button样式
  68. styleOption: {
  69. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  70. .fontSize(20)
  71. .fontColor(Color.Black)
  72. },
  73. },
  74. // OpenType为“REAL_NAME_AUTHENTICATION”时,回调必须选择“onRealNameAuthentication”
  75. controller: new functionalButtonComponentManager.FunctionalButtonController()
  76. .onRealNameAuthentication((err, data) => {
  77. if (err) {
  78. // 错误日志处理
  79. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  80. return;
  81. }
  82. // 成功日志处理
  83. hilog.info(0x0000, "testTag", "succeeded in authenticating");
  84. // 获取Authorization Code
  85. let authCode: string = data.authCode as string;
  86. let openID: string = data.openID as string;
  87. // sceneid调用场景 0:开放实名信息校验场景;1:人脸核身,验证姓名/证件类型/证件号/人脸场景;2:人脸核身,验证人脸场景
  88. this.obtainRealNameDataInfo(authCode, 0, openID, 'name', 'idNo', (err, data) => {
  89. if (err) {
  90. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  91. return;
  92. }
  93. let state = data.state;
  94. let realNameLevel = data.realNameLevel;
  95. let verifyResult = data.verifyResult;
  96. let verifyToken = data.verifyToken;
  97. hilog.info(0x0000, "testTag", "succeeded in verifying");
  98. })
  99. })
  100. })
  101. }
  102. .width('100%')
  103. }
  104. .height('100%')
  105. }
  106. }

onFaceAuthentication

onFaceAuthentication(callback: AsyncCallback<FaceAuthenticationResult>): FunctionalButtonController

注册FunctionalButton组件为人脸核身的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<FaceAuthenticationResult>

回调函数。callback返回人脸核身鉴权对应的返回体:authCode、openID。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import { http } from '@kit.NetworkKit';
  4. import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
  5. interface Result {
  6. state?: number;
  7. realNameLevel?: number;
  8. verifyResult?: number;
  9. verifyToken?: string;
  10. }
  11. @Entry
  12. @Component
  13. struct SecondPage {
  14. obtainFaceVerifyDataInfo(authCode: string, sceneID: number, openID: string, realName: string, idNo: string,
  15. callback: AsyncCallback<Result>) {
  16. // 每一个httpRequest对应一个HTTP请求任务,不可复用
  17. let httpRequest = http.createHttp();
  18. // 用于订阅HTTP响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息
  19. httpRequest.on('headersReceive', (header) => {
  20. hilog.info(0x0000, "testTag", "header: %{public}s", header as string);
  21. });
  22. httpRequest.request(
  23. // 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定
  24. "EXAMPLE_URL",
  25. {
  26. method: http.RequestMethod.POST,
  27. // 开发者根据自身业务需要添加header字段
  28. header: {
  29. 'Content-Type': 'application/json'
  30. },
  31. // 当使用POST请求时此字段用于传递内容
  32. extraData: {
  33. "authCode": authCode,
  34. "sceneID": sceneID,
  35. "openID": openID,
  36. "realname": realName,
  37. "idNo": idNo,
  38. },
  39. expectDataType: http.HttpDataType.STRING,
  40. usingCache: true,
  41. priority: 1,
  42. connectTimeout: 60000,
  43. readTimeout: 60000,
  44. usingProtocol: http.HttpProtocol.HTTP1_1,
  45. }, (err, data) => {
  46. if (!err) {
  47. let res: Result = JSON.parse(data.result as string);
  48. callback(undefined, res);
  49. } else {
  50. let error: BusinessError = { code: err.code, message: err.message, name: '' };
  51. callback(error, undefined);
  52. // 取消订阅HTTP响应头事件
  53. httpRequest.off('headersReceive');
  54. // 当该请求使用完毕时,调用destroy方法主动销毁
  55. httpRequest.destroy();
  56. }
  57. })
  58. }
  59. build() {
  60. Row() {
  61. Column() {
  62. FunctionalButton({
  63. params: {
  64. // OpenType.FACE_AUTHENTICATION表示Button为人脸核身类型
  65. openType: functionalButtonComponentManager.OpenType.FACE_AUTHENTICATION,
  66. label: '人脸核身',
  67. // 调整Button样式
  68. styleOption: {
  69. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  70. .fontSize(20)
  71. .fontColor(Color.Black)
  72. },
  73. },
  74. // OpenType为“FACE_AUTHENTICATION”时,回调必须选择“onFaceAuthentication”
  75. controller: new functionalButtonComponentManager.FunctionalButtonController()
  76. .onFaceAuthentication((err, data) => {
  77. if (err) {
  78. // 错误日志处理
  79. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  80. return;
  81. }
  82. // 成功日志处理
  83. hilog.info(0x0000, "testTag", "succeeded in authenticating");
  84. // 获取Authorization Code
  85. let authCode: string = data.authCode as string;
  86. let openID: string = data.openID as string;
  87. hilog.info(0x0000, "testTag", "succeeded in authCode");
  88. // sceneid调用场景 0:开放实名信息校验场景;1:人脸核身,验证姓名/证件类型/证件号/人脸场景;2:人脸核身,验证人脸场景
  89. this.obtainFaceVerifyDataInfo(authCode, 2, openID, "", "", (err, data) => {
  90. if (err) {
  91. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  92. return;
  93. }
  94. let verifyToken: string = data.verifyToken as string;
  95. new functionalButtonComponentManager.FunctionalButtonController().onFaceVerification(verifyToken,
  96. (error, data) => {
  97. if (error) {
  98. // 错误日志处理
  99. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", error.code, error.message);
  100. return;
  101. }
  102. let facialRecognitionVerificationToken = data.facialRecognitionVerificationToken;
  103. let state = data.state;
  104. hilog.info(0x0000, 'testTag', 'auth result success');
  105. });
  106. })
  107. })
  108. })
  109. }
  110. .width('100%')
  111. }
  112. .height('100%')
  113. }
  114. }

onFaceVerification

onFaceVerification(verifyToken: string, callback: AsyncCallback<FaceVerificationResult>): void

注册FunctionalButton组件为人脸验证的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

verifyToken

string

验证成功的idToken,三方应用拉起华为账号客户端人脸验证页面时传入此Token,供华为账号客户端校验验证结果。

callback

AsyncCallback<FaceVerificationResult>

回调函数。callback返回人脸验证的结果。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import { http } from '@kit.NetworkKit';
  4. import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
  5. interface Result {
  6. state?: number;
  7. realNameLevel?: number;
  8. verifyResult?: number;
  9. verifyToken?: string;
  10. }
  11. @Entry
  12. @Component
  13. struct SecondPage {
  14. obtainFaceVerifyDataInfo(authCode: string, sceneID: number, openID: string, realName: string, idNo: string,
  15. callback: AsyncCallback<Result>) {
  16. // 每一个httpRequest对应一个HTTP请求任务,不可复用
  17. let httpRequest = http.createHttp();
  18. // 用于订阅HTTP响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息
  19. httpRequest.on('headersReceive', (header) => {
  20. hilog.info(0x0000, "testTag", "header: %{public}s", header as string);
  21. });
  22. httpRequest.request(
  23. // 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定
  24. "EXAMPLE_URL",
  25. {
  26. method: http.RequestMethod.POST,
  27. // 开发者根据自身业务需要添加header字段
  28. header: {
  29. 'Content-Type': 'application/json'
  30. },
  31. // 当使用POST请求时此字段用于传递内容
  32. extraData: {
  33. "authCode": authCode,
  34. "sceneID": sceneID,
  35. "openID": openID,
  36. "realname": realName,
  37. "idNo": idNo,
  38. },
  39. expectDataType: http.HttpDataType.STRING,
  40. usingCache: true,
  41. priority: 1,
  42. connectTimeout: 60000,
  43. readTimeout: 60000,
  44. usingProtocol: http.HttpProtocol.HTTP1_1,
  45. }, (err, data) => {
  46. if (!err) {
  47. let res: Result = JSON.parse(data.result as string);
  48. callback(undefined, res);
  49. } else {
  50. let error: BusinessError = { code: err.code, message: err.message, name: '' };
  51. callback(error, undefined);
  52. // 取消订阅HTTP响应头事件
  53. httpRequest.off('headersReceive');
  54. // 当该请求使用完毕时,调用destroy方法主动销毁
  55. httpRequest.destroy();
  56. }
  57. })
  58. }
  59. build() {
  60. Row() {
  61. Column() {
  62. FunctionalButton({
  63. params: {
  64. // OpenType.FACE_AUTHENTICATION表示Button为人脸核身类型
  65. openType: functionalButtonComponentManager.OpenType.FACE_AUTHENTICATION,
  66. label: '人脸核身',
  67. // 调整Button样式
  68. styleOption: {
  69. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  70. .fontSize(20)
  71. .fontColor(Color.Black)
  72. },
  73. },
  74. // OpenType为“FACE_AUTHENTICATION”时,回调必须选择“onFaceAuthentication”
  75. controller: new functionalButtonComponentManager.FunctionalButtonController()
  76. .onFaceAuthentication((err, data) => {
  77. if (err) {
  78. // 错误日志处理
  79. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  80. return;
  81. }
  82. // 成功日志处理
  83. hilog.info(0x0000, "testTag", "succeeded in authenticating");
  84. // 获取Authorization Code
  85. let authCode: string = data.authCode as string;
  86. let openID: string = data.openID as string;
  87. hilog.info(0x0000, "testTag", "succeeded in authCode");
  88. // sceneid调用场景 0:开放实名信息校验场景;1:人脸核身,验证姓名/证件类型/证件号/人脸场景;2:人脸核身,验证人脸场景
  89. this.obtainFaceVerifyDataInfo(authCode, 2, openID, "", "", (err, data) => {
  90. if (err) {
  91. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  92. return;
  93. }
  94. let verifyToken: string = data.verifyToken as string;
  95. new functionalButtonComponentManager.FunctionalButtonController().onFaceVerification(verifyToken,
  96. (error, data) => {
  97. if (error) {
  98. // 错误日志处理
  99. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", error.code, error.message);
  100. return;
  101. }
  102. let facialRecognitionVerificationToken = data.facialRecognitionVerificationToken;
  103. let state = data.state;
  104. hilog.info(0x0000, 'testTag', 'auth result success');
  105. });
  106. })
  107. })
  108. })
  109. }
  110. .width('100%')
  111. }
  112. .height('100%')
  113. }
  114. }

onChooseLocation

onChooseLocation(callback: AsyncCallback<ChooseLocationResult>): FunctionalButtonController

注册FunctionalButton组件为打开地图选点的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<ChooseLocationResult>

回调函数。callback返回打开地图选点的结果。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.CHOOSE_LOCATION表示Button为地图选点
  13. openType: functionalButtonComponentManager.OpenType.CHOOSE_LOCATION,
  14. label: '地图选点',
  15. // 调整Button样式
  16. styleOption: {
  17. bgColor:functionalButtonComponentManager.ColorType.DEFAULT,
  18. size: functionalButtonComponentManager.SizeType.DEFAULT,
  19. plain: false,
  20. disabled:false,
  21. loading: false,
  22. hoverClass: functionalButtonComponentManager.HoverClassType.HOVER_CLASS,
  23. hoverStartTime: 0,
  24. hoverStayTime: 0,
  25. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  26. .fontSize(20)
  27. .fontColor(Color.Black)
  28. }
  29. },
  30. // OpenType为“CHOOSE_LOCATION”时,回调必须选择“onChooseLocation”
  31. controller: new functionalButtonComponentManager.FunctionalButtonController()
  32. .onChooseLocation((err, data) => {
  33. if (err) {
  34. // 错误日志处理
  35. hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message);
  36. return;
  37. }
  38. // 成功日志处理
  39. hilog.info(0x0000, "testTag", "succeeded in choosing location");
  40. let name: string = data.name;
  41. let address: string = data.address;
  42. let longitude: number = data.longitude;
  43. let latitude: number = data.latitude;
  44. })
  45. })
  46. }.width('100%')
  47. }.height('100%')
  48. }
  49. }

onSubscribeLiveView

onSubscribeLiveView(callback: AsyncCallback<SubscribeLiveViewResult>): FunctionalButtonController

注册FunctionalButton组件为实况窗订阅的点击事件,使用callback异步回调。

模型约束:此接口仅可在Stage模型下使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

callback

AsyncCallback<SubscribeLiveViewResult>

回调函数。callback会返回实况订阅的结果。

返回值:

展开

类型

说明

FunctionalButtonController

FunctionalButton组件控制器。

示例:

收起
自动换行
深色代码主题
复制
  1. import { hilog } from '@kit.PerformanceAnalysisKit';
  2. import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit';
  3. @Entry
  4. @Component
  5. struct Index {
  6. build() {
  7. Row() {
  8. Column() {
  9. // 声明FunctionalButton
  10. FunctionalButton({
  11. params: {
  12. // OpenType.SUBSCRIBE_LIVE_VIEW表示Button为实况窗订阅类型
  13. openType: functionalButtonComponentManager.OpenType.SUBSCRIBE_LIVE_VIEW,
  14. label: '预约抢购',
  15. // 调整Button样式
  16. styleOption: {
  17. styleConfig: new functionalButtonComponentManager.ButtonConfig()
  18. .fontSize(20)
  19. .fontColor(Color.Black)
  20. },
  21. subscribeLiveViewParam: {
  22. event: "SUBSCRIBE_TIMER",
  23. alertTime: 172178838111,
  24. startTime: 172170198111
  25. },
  26. },
  27. // OpenType为“SUBSCRIBE_LIVE_VIEW”时,回调必须选择“onSubscribeLiveView”
  28. controller: new functionalButtonComponentManager.FunctionalButtonController().onSubscribeLiveView((err,
  29. data) => {
  30. if (err) {
  31. // 错误日志处理
  32. hilog.error(0x0000, "testTag", `error code is: ${err?.code} message is ${err?.message}`);
  33. return;
  34. }
  35. let subscribeId = data.subscribeId;
  36. // 成功日志处理
  37. hilog.info(0x0000, "testTag", "successed in subscribing LiveView");
  38. })
  39. })
  40. }
  41. .width('100%')
  42. }
  43. .height('100%')
  44. }
  45. }

ButtonConfig

该类提供了实现FunctionalButton自定义属性的方法。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

type

type(value: ButtonType): ButtonConfig

设置FunctionalButton的显示样式属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ButtonType

描述按钮显示样式。

默认值:ButtonType.Capsule

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

stateEffect

stateEffect(value: boolean): ButtonConfig

设置FunctionalButton是否开启按压态显示效果属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

boolean

按钮按下时是否开启按压态显示效果,当设置为false时,按压效果关闭;设置为true时,按压效果开启。

默认值:true

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

fontColor

fontColor(value: ResourceColor): ButtonConfig

设置FunctionalButton的字体颜色属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ResourceColor

设置字体颜色。

默认值:#ffffff

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

fontSize

fontSize(value: Length): ButtonConfig

设置FunctionalButton的字体大小属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length

设置字体大小,Length为number类型时,使用fp单位。

字体默认大小16fp。不支持设置百分比字符串。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

fontWeight

fontWeight(value: string | number | FontWeight): ButtonConfig

设置FunctionalButton的字体粗细属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

string | number | FontWeight

设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium"、"normal",分别对应FontWeight中相应的枚举值。

默认值:FontWeight.Normal

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

fontStyle

fontStyle(value: FontStyle): ButtonConfig

设置FunctionalButton的字体样式属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

FontStyle

设置字体样式。

默认值:FontStyle.Normal

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

fontFamily

fontFamily(value: string | Resource): ButtonConfig

设置FunctionalButton的字体属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

string | Resource

设置字体列表。默认字体'HarmonyOS Sans',当前支持'HarmonyOS Sans'字体和注册自定义字体

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

width

width(value: Length): ButtonConfig

设置FunctionalButton的宽度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length

设置组件自身的宽度,缺省时使用元素自身内容需要的宽度。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

height

height(value: Length): ButtonConfig

设置FunctionalButton的高度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length

设置组件自身的高度,缺省时使用元素自身内容需要的高度。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

size

size(value: SizeOptions): ButtonConfig

设置FunctionalButton的高宽尺寸属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

SizeOptions

设置高宽尺寸。举例:

收起
自动换行
深色代码主题
复制
  1. {
  2. width: 20,
  3. height: 50
  4. }

单位:vp。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

constraintSize

constraintSize(value: ConstraintSizeOptions): ButtonConfig

设置FunctionalButton的约束尺寸属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ConstraintSizeOptions

设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于width和height。取值结果参考constraintSize取值对width/height影响

默认值:

收起
自动换行
深色代码主题
复制
  1. {
  2. minWidth: 0,
  3. maxWidth: Infinity,
  4. minHeight: 0,
  5. maxHeight: Infinity
  6. }

单位:vp。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

padding

padding(value: Length | Padding): ButtonConfig

设置FunctionalButton的内边距属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length | Padding

设置内边距属性。

参数为Length类型时,四个方向内边距同时生效。

默认值:0

单位:vp。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

margin

margin(value: Length | Padding): ButtonConfig

设置FunctionalButton的外边距属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length | Padding

设置外边距属性。

参数为Length类型时,四个方向外边距同时生效。

默认值:0

单位:vp。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

backgroundColor

backgroundColor(value: ResourceColor): ButtonConfig

设置FunctionalButton的背景色属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ResourceColor

设置组件的背景色。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

backgroundImage

backgroundImage(src: ResourceStr, repeat?: ImageRepeat): ButtonConfig

设置FunctionalButton的背景图像属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

src

ResourceStr

图片地址,支持网络图片资源和本地图片资源地址,不支持svg类型的图片。

repeat

ImageRepeat

设置背景图的重复样式,默认不重复。当设置的背景图片为透明底色图片,且同时设置了backgroundColor时,二者叠加显示,背景颜色在最底部。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

backgroundImageSize

backgroundImageSize(value: SizeOptions | ImageSize): ButtonConfig

设置FunctionalButton的背景图像的高度和宽度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

SizeOptions | ImageSize

设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。

width和height取值范围: [0, +∞)

默认值:ImageSize.Auto

说明

设置为小于0的值时,按值为0显示。当设置了height未设置width时,width根据图片原始宽高比进行调整。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

backgroundImagePosition

backgroundImagePosition(value: Position | Alignment): ButtonConfig

设置FunctionalButton的背景图像的显示位置属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Position | Alignment

设置背景图像在组件中显示位置,即相对于组件左上角的坐标。

默认值:

收起
自动换行
深色代码主题
复制
  1. {
  2. x: 0,
  3. y: 0
  4. }

x和y值设置百分比时,偏移量是相对组件自身宽高计算的。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

opacity

opacity(value: number | Resource): ButtonConfig

设置FunctionalButton的透明度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

number | Resource

元素的不透明度,取值范围为0到1,1表示不透明,0表示完全透明, 达到隐藏组件效果,但是在布局中占位。

说明

子组件可以继承父组件的此属性。默认值:1

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

border

border(value: BorderOptions): ButtonConfig

统一设置FunctionalButton的边框宽度、边框颜色、边框圆角半径、边框样式属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

BorderOptions

统一边框样式设置接口。

- width:设置边框宽度。

- color:设置边框颜色。

- radius:设置边框圆角半径。

- style:设置边框样式。

说明

边框宽度默认值为0,即不显示边框。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

borderStyle

borderStyle(value: BorderStyle | EdgeStyles): ButtonConfig

设置FunctionalButton的边框样式属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

BorderStyle | EdgeStyles

设置元素的边框样式。

默认值:BorderStyle.Solid

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

borderWidth

borderWidth(value: Length | EdgeWidths): ButtonConfig

设置FunctionalButton的边框宽度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length | EdgeWidths

设置元素的边框宽度,不支持百分比。

默认值:1,单位:vp。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

borderColor

borderColor(value: ResourceColor | EdgeColors): ButtonConfig

设置FunctionalButton的边框颜色属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ResourceColor | EdgeColors

设置元素的边框颜色。

默认值:#000000

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

borderRadius

borderRadius(value: Length | BorderRadiuses): ButtonConfig

设置FunctionalButton的边框圆角半径属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length | BorderRadiuses

设置元素的边框圆角半径,不支持百分比。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

borderImage

borderImage(value: BorderImageOption): ButtonConfig

设置FunctionalButton的图片边框属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

BorderImageOption

图片边框或者渐变色边框设置接口。

该接口支持在ArkTS卡片中使用。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

scale

scale(value: ScaleOptions): ButtonConfig

设置FunctionalButton的缩放属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ScaleOptions

可以分别设置X轴、Y轴、Z轴的缩放比例,默认值为1.0,同时可以通过centerX和centerY设置缩放的中心点。

默认值:

收起
自动换行
深色代码主题
复制
  1. {
  2. x: 1.0,
  3. y: 1.0,
  4. z: 1.0,
  5. centerX:'0.5',
  6. centerY:'0.5'
  7. }

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

align

align(value: Alignment): ButtonConfig

设置FunctionalButton的对齐方式属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Alignment

设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。

默认值:Alignment.Center

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

markAnchor

markAnchor(value: Position): ButtonConfig

设置FunctionalButton在位置定位时的锚点。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Position

设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。

默认值:

收起
自动换行
深色代码主题
复制
  1. {
  2. x: 0,
  3. y: 1
  4. }

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

offset

offset(value: Position): ButtonConfig

设置FunctionalButton在位置坐标偏移量。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Position

设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。

默认值:

收起
自动换行
深色代码主题
复制
  1. {
  2. x: 0,
  3. y: 1
  4. }

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

enabled

enabled(value: boolean): ButtonConfig

设置FunctionalButton的是否禁用属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

boolean

值为true表示组件可交互,响应点击等操作。

值为false表示组件不可交互,不响应点击等操作。

默认值:true

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

loadingColor

loadingColor(value: ResourceColor): ButtonConfig

设置FunctionalButton中的LoadingProgress图标的颜色属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

ResourceColor

设置图标颜色。默认值:#FFFFFF

说明

设置为异常值时,按值为'#ff666666'显示。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

loadingWidth

loadingWidth(value: Length): ButtonConfig

设置FunctionalButton中的LoadingProgress图标的宽度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length

设置图标自身的宽度。默认值:20,单位:vp。

取值范围:(-∞, +∞)

填写为负数时,宽度不超过按钮大小;填写正数时,宽度不受限于按钮大小,请合理填写数值。

说明

LoadingProgress图标始终保持正方形,在显示时边长会取loadingWidth和loadingHeight中的最小值。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

loadingHeight

loadingHeight(value: Length): ButtonConfig

设置FunctionalButton中的LoadingProgress图标的高度属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length

设置图标自身的高度。默认值:20,单位:vp。

取值范围:(-∞, +∞)

填写为负数时,高度不超过按钮大小。填写正数时,高度不受限于按钮大小,请合理填写数值。

说明

LoadingProgress图标始终保持正方形,在显示时边长会取loadingWidth和loadingHeight中的最小值。

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

loadingPadding

loadingPadding(value: Length | Padding): ButtonConfig

设置FunctionalButton中的LoadingProgress图标的内边距属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length | Padding

设置图标内边距属性。单位:vp。

默认值:0

取值范围:(-∞, +∞)

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

loadingMargin

loadingMargin(value: Length | Padding): ButtonConfig

设置FunctionalButton中的LoadingProgress图标的外边距属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力SystemCapability.AtomicserviceComponent.UIComponent

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

value

Length | Padding

设置图标外边距属性。单位:vp。

默认值:{left: -2, right: 2}

取值范围:(-∞, +∞)

返回值:

展开

类型

说明

ButtonConfig

ButtonConfig对象。

在 API参考 中进行搜索
请输入您想要搜索的关键词