Skip to content

基础使用

通过 text 属性设置按钮文字。

vue
<hi-button text="基础使用"></hi-button>

禁用按钮

添加 disabled 属性,即可得到一个禁用按钮。

vue
<hi-button text="禁用按钮" disabled></hi-button>

图标按钮

hi-button 组件支持设置前置(左侧)和后置(右侧)两种图标。

vue
<hi-button text="前置图标" leftIconName="__gonggao"></hi-button>
<hi-button text="后置图标" rightIconName="__fuzhi"></hi-button>
<hi-button text="前后图标" leftIconName="__gonggao" rightIconName="__fuzhi"></hi-button>

loading 按钮

添加 loading 属性,即可得到一个加载中的按钮。
通过设置 loadingText 属性来设置 loading 时显示的提示。
通过设置 loadingIconName 属性来自定义 loading 图标。

vue
<hi-button text="加载按钮" loading></hi-button>
<hi-button text="加载按钮" loading loadingText="正在努力加载中..."></hi-button>

按钮副文字

hi-button 支持通过 subText 属性设置按钮的副文字,显示在主文字的下方。

vue
<hi-button text="带副文字的按钮" subText="我是副文字"></hi-button>

Props

uni-app buttom 组件自带的属性说明参考 uni-app button 组件官方文档

参数说明类型默认值可选值
hoverClass按钮点击时的类名Stringhi-hover-
disabled是否禁用Booleanfalse-
debounce是否开启防抖Booleanfalse-
debounceTime防抖间隔,即两次点击之间的间隔,毫秒Number800-
text按钮主文字String--
subText按钮副文字String--
loading是否显示 loadingBoolean--
loadingTextloading 时显示的提示String--
loadingIconNameloading 图标名称String__loading-
leftIconName左侧图标的名称String--
rightIconName右侧图标的名称String--
formType用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件String--
openType开放能力String--
hoverStartTime按住后多久出现点击态,单位毫秒Number20-
hoverStayTime手指松开后点击态保留时间,单位毫秒Number70-
appParameter打开 APP 时,向 APP 传递的参数,open-type=launchApp 时有效String--
hoverStopPropagation指定是否阻止本节点的祖先节点出现点击态Booleanfalse-
lang指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。Stringzh_CN-
sessionFrom会话来源,open-type="contact" 时有效String--
sendMessageTitle会话内消息卡片标题,open-type="contact" 时有效String--
sendMessagePath会话内消息卡片点击跳转小程序路径,open-type="contact" 时有效String--
sendMessageImg会话内消息卡片图片,open-type="contact" 时有效String--
showMessageCard是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact" 时有效Booleanfalse-
groupId打开群资料卡时,传递的群号String--
guildId打开频道页面时,传递的频道号String--
publicId打开公众号资料卡时,传递的号码String--
dataImId客服的抖音号String--
dataImTypeIM 卡片类型String--
dataGoodsId商品的 id,仅支持泛知识课程库和生活服务商品库中的商品String--
dataOrderId订单的 id,仅支持交易 2.0 订单String--
dataBizLine商品类型,“1” 代表生活服务,“2” 代表泛知识。String--

Events

具体的事件说明参考 uni-app button 组件官方文档

事件名说明回调参数
@getphonenumber获取用户手机号回调-
@getuserinfo用户点击该按钮时,会返回获取到的用户信息,从返回参数的 detail 中获取到的值同 uni.getUserInfo-
@error当使用开放能力时,发生错误的回调-
@open-setting在打开授权设置页并关闭后回调-
@launchapp从小程序打开 App 成功的回调-
@contact客服消息回调-
@chooseavatar获取用户头像回调-
@agreeprivacyauthorization用户同意隐私协议事件回调,open-type="agreePrivacyAuthorization" 时有效-
@addgroupapp添加群应用的回调-
@chooseaddress调起用户编辑并选择收货地址的回调-
@chooseinvoicetitle用户选择发票抬头的回调-
@subscribe订阅消息授权回调-
@login登录回调-
@im监听跳转 IM 的成功回调-

Slots

名称说明
#default按钮文本内容插槽,