For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/components/form/button.md.

button

按钮组件。

扫码预览

扫码预览 button

Props

属性名类型默认值必填说明
childrenReactNode-否子元素,用于自定义内容。当同时提供 icon/text 和 children 时,children 优先。
classNamestring-否组件类名
disabledbooleanfalse否是否禁用
iconReactNode-否图标,显示在文字前面
keystring | number | null-否React key 属性
launchAppUrlstring-否跳转外部应用的 deeplink URL,只在 openType="launchApp" 时有效。
前端库版本不低于 0.1.1。
loadingbooleanfalse否是否显示加载状态
onAgreePrivacyAuthorization(result?: AgreePrivacyResult) => void-否授权隐私协议回调,只在 openType="agreePrivacyAuthorization" 时有效
onClick(event?: TouchEvent) => void-否点击回调函数
onDisabledClick(event?: TouchEvent) => void-否禁用状态下的点击回调函数
onGetPhoneNumber(result?: GetPhoneNumberResult) => void-否获取用户手机号回调,只在 openType="getPhoneNumber" 时有效
onLaunchApp(result: OpenAppResult) => void-否跳转外部应用回调,只在 openType="launchApp" 时有效。

仅在跳转成功时返回跳转结果。
前端库版本不低于 0.1.1。
onLaunchAppError(error: unknown) => void-否跳转外部应用失败回调,只在 openType="launchApp" 时有效。
前端库版本不低于 0.1.1。
onOpenSetting(event: OpenSettingEvent) => void-否打开授权设置页回调,只在 openType="openSetting" 时有效

成功时 detail 包含 errMsg: 'openSetting:ok' 和最新 authSetting;
失败时 detail 仅包含 openSetting:fail ...,不会包含 authSetting 字段。
openType"getPhoneNumber"
| "agreePrivacyAuthorization"
| "agreePrivacyAuthorization|getPhoneNumber"
| "openSetting"
| "launchApp"
-否开放能力类型
showDisabledStylebooleantrue否是否展示组件内置的禁用态样式
sizeButtonSize'default'否按钮尺寸
styleCSSProperties-否组件样式
textstring-否按钮文字
throttlenumber500否onClick 的节流时间,单位为毫秒
typeButtonType'primary'否按钮样式类型

使用建议

由于组件不开启 CSS 继承,button 的文本样式不会自动应用到 children。 因此提供了以下明确的 API 用法:

  • text:传入字符串,按钮会应用默认文本样式
  • icon + text:组合使用,显示图标和文字
  • children:完全自定义内容,不会应用按钮的默认文本样式
// 简单文字:用 text(推荐)
<button text="确定" />

// 图标+文字:用 icon + text
<button icon={<Icon />} text="提交" />

// 完全自定义:用 children(无默认样式)
<button>
  <text style={{ color: 'red' }}>自定义</text>
</button>