Skip to content

Button

基础用法

html

<pa-button type="primary">主要按钮</pa-button>
<pa-button type="warning">警告按钮</pa-button>
<pa-button type="danger">危险按钮</pa-button>
<pa-button type="default">默认按钮</pa-button>

镂空按钮

html

<pa-button type="primary" plain>镂空按钮</pa-button>
<pa-button type="warning" plain>镂空按钮</pa-button>
<pa-button type="danger" plain>镂空按钮</pa-button>

禁用状态

html

<pa-button type="primary" disabled>禁用状态</pa-button>

尺寸

html

<pa-button type="primary" size="large">大号按钮</pa-button>
<pa-button type="primary" size="normal">普通按钮</pa-button>
<pa-button type="primary" size="small">小型按钮</pa-button>
<pa-button type="primary" size="mini">迷你按钮</pa-button>

自定义大小

html

<pa-button type="primary" width="300" height="80">按钮</pa-button>
<pa-button type="primary" width="200" height="60">按钮</pa-button>

圆角

html

<pa-button type="primary" round>圆角按钮</pa-button>
<pa-button type="primary" round="20">圆角按钮</pa-button>

加载状态

html

<pa-button type="primary" loading>加载状态</pa-button>

图标

html

<pa-button type="primary" icon="write">图标按钮</pa-button>
<pa-button type="primary" icon="write"></pa-button>
<pa-button type="primary" icon="write" width="42px" height="42px" round></pa-button>

块级元素

html

<pa-button type="primary" block>块级元素</pa-button>

点击加载(等待promise)

html

<pa-button type="primary" :sync-click="onClick">点击加载</pa-button>
ts

const onClick = () => {
  return new Promise<void>((resolve) => {
    setTimeout(() => {
      resolve()
    }, 2000)
  })
}

Button Props

参数说明类型默认值
buttonId标识符,作为原生button组件的id值string-
type按钮类型'primary'|'warning'|'danger'|'default''primary'
width按钮宽度string-
height按钮高度string-
size尺寸'large'|'normal'|'small'|'mini''normal'
fontSize字体大小string-
block是否为块级元素boolean-
loading是否显示为加载状态boolean-
loadingText加载状态提示文字string-
disabled是否禁用boolean-
round圆角大小, 值为true时半圆角boolean | string-
plain是否镂空样式boolean-
icon图标string-
ellipsis文本省略boolean-
syncClick同步点击(主要用于防止异步事件多次触发)(...args:any[])=>any|Promise<any>-
customStyle自定义样式CSSProperties-
openType微信开放能力文档'contact'|'share'|'getPhoneNumber'|'getUserInfo'
|'launchApp'|'openSetting'|'feedback'|'chooseAvatar'
|'getRealtimePhoneNumber'|'agreePrivacyAuthorization'
-
hoverStartTime按住后多久出现点击态,单位毫秒number-
hoverStayTime手指松开后点击态保留时间,单位毫秒number-
appParameter打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效string-
hoverStopPropagation指定是否阻止本节点的祖先节点出现点击态boolean-
lang指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。'zh_CN'|'zh_TW'|'en'-
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"时有效boolean-

Button Event

事件名参数
click(value: Event)
getphonenumber(res: any)
getuserinfo(res: any)
error(res: any)
opensetting(res: any)
launchapp(res: any)
contact(res: any)
chooseavatar(res: any)
getrealtimephonenumber(res: any)
agreeprivacyauthorization(res: any)

Button Slot

名称说明
default-

样式变量

名称默认值
--pa-button-height44px
--pa-button-line-height1.2
--pa-button-margin0
--pa-button-border-width1px
--pa-button-border-colortransparent
--pa-button-border-radius5px
--pa-button-colorvar(--pa-color-black)
--pa-button-background#fff
--pa-button-border-color#ebedf0
--pa-button-primary-color#fff
--pa-button-primary-backgroundvar(--pa-color-primary)
--pa-button-primary-border-colorvar(--pa-color-primary)
--pa-button-warning-color#fff
--pa-button-warning-backgroundvar(--pa-color-warning)
--pa-button-warning-border-colorvar(--pa-color-warning)
--pa-button-danger-color#fff
--pa-button-danger-backgroundvar(--pa-color-danger)
--pa-button-danger-border-colorvar(--pa-color-danger)
--pa-button-large-height50px
--pa-button-large-font-size16px
--pa-button-font-size14px
--pa-button-padding0 15px
--pa-button-small-height32px
--pa-button-small-font-size12px
--pa-button-padding0 8px
--pa-button-mini-height24px
--pa-button-mini-font-size10px
--pa-button-padding0 4px
--pa-button-disabled-background#c8c9cc
--pa-button-disabled-border-color#c8c9cc