按钮 
按钮组件。
文本 
- 按钮文本可以通过 
text属性设置。 - 也可以通过默认插槽设置按钮内容。
 
vue
<template>
	<!-- 按钮文本 -->
	<pure-button text="按钮"></pure-button>
	<!-- 按钮内容 -->
	<pure-button>
		<pure-icon name="__loading"></pure-icon>
	</pure-button>
</template>边框 
- 按钮默认无边框。
 - 主题按钮、幽灵按钮、镂空按钮默认有边框。
 - 可以通过 
border属性设置边框。 - 边框颜色默认为按钮文字颜色,即 
currentColor。 
vue
<template>
	<pure-button text="边框按钮" border></pure-button>
</template>主题 
通过 theme 属性设置按钮主题。有关主题的使用请参考 主题。
vue
<template>
	<!-- 内置主题 -->
	<pure-button text="主要按钮" theme="primary"></pure-button>
	<pure-button text="成功按钮" theme="success"></pure-button>
	<pure-button text="警告按钮" theme="warning"></pure-button>
	<pure-button text="危险按钮" theme="danger"></pure-button>
	<pure-button text="信息按钮" theme="info"></pure-button>
	<!-- 自定义主题 -->
	<pure-button text="自定义主题" theme="haha"></pure-button>
	<pure-button text="自定义主题" theme="--my-theme-hoho"></pure-button>
</template>
<style scoped lang="scss">
page {
	--pure-theme-haha: #007bff;
	--my-theme-hoho: #ff007b;
}
</style>幽灵按钮 
- 幽灵按钮是指按钮文字颜色与背景颜色相同,但背景颜色相对颜色较浅。
 - 通过 
ghost属性设置幽灵按钮。 
vue
<template>
	<!-- 内置主题 -->
	<pure-button text="主要按钮" ghost theme="primary"></pure-button>
	<pure-button text="成功按钮" ghost theme="success"></pure-button>
	<pure-button text="警告按钮" ghost theme="warning"></pure-button>
	<pure-button text="危险按钮" ghost theme="danger"></pure-button>
	<pure-button text="信息按钮" ghost theme="info"></pure-button>
	<!-- 自定义主题 -->
	<pure-button text="自定义主题" ghost theme="haha"></pure-button>
	<pure-button text="自定义主题" ghost theme="--my-theme-hoho"></pure-button>
</template>
<style scoped lang="scss">
page {
	--pure-theme-haha: #007bff;
	--my-theme-hoho: #ff007b;
}
</style>镂空按钮 
- 镂空按钮是指按钮背景透明。
 - 通过 
plain属性设置镂空按钮。 
vue
<template>
	<!-- 内置主题 -->
	<pure-button text="主要按钮" plain theme="primary"></pure-button>
	<pure-button text="成功按钮" plain theme="success"></pure-button>
	<pure-button text="警告按钮" plain theme="warning"></pure-button>
	<pure-button text="危险按钮" plain theme="danger"></pure-button>
	<pure-button text="信息按钮" plain theme="info"></pure-button>
	<!-- 自定义主题 -->
	<pure-button text="自定义主题" plain theme="haha"></pure-button>
	<pure-button text="自定义主题" plain theme="--my-theme-hoho"></pure-button>
</template>
<style scoped lang="scss">
page {
	--pure-theme-haha: #007bff;
	--my-theme-hoho: #ff007b;
}
</style>图标 
- 通过 
iconName属性设置前置图标。 - 通过 
afterIconName属性设置后置图标。 - 通过 
iconOpts属性设置前置图标配置。 - 通过 
afterIconOpts属性设置后置图标配置。 
vue
<template>
	<pure-button text="前置图标" iconName="__arrow-left"></pure-button>
	<pure-button text="后置图标" afterIconName="__arrow-right"></pure-button>
	<pure-button text="前后图标" iconName="__arrow-left" afterIconName="__arrow-right"></pure-button>
</template>按钮形状 
通过 shape 属性设置按钮形状,可选值为:
square—— 矩形round—— 圆角cube—— 方块按钮circle—— 圆形按钮
vue
<template>
	<pure-button text="矩形按钮" shape="square"></pure-button>
	<pure-button text="圆角按钮" shape="round"></pure-button>
	<pure-button text="方块按钮" shape="cube"></pure-button>
	<pure-button text="圆形按钮" shape="circle"></pure-button>
</template>块状按钮 
通过 block 属性设置按钮是否为块状按钮,表现样式为宽度 100%。
vue
<template>
	<pure-button text="块状按钮" block theme="primary"></pure-button>
</template>链接按钮 
- 通过 
link属性设置按钮是否为连接按钮,表现样式类似于超链接。 - 通过 
underline属性设置是否显示下划线,默认值为false。 
vue
<template>
	<pure-button text="连接按钮" link theme="primary"></pure-button>
	<pure-button text="带下划线" link theme="primary" underline></pure-button>
</template>禁用状态 
通过 disabled 属性设置按钮是否为禁用状态,默认值为 false。
vue
<template>
	<pure-button text="连接按钮" disabled theme="primary"></pure-button>
	<pure-button text="带下划线" disabled theme="primary"></pure-button>
</template>加载状态 
- 通过 
loading属性设置按钮是否为加载状态,默认值为false。 - 通过 
loadingText属性设置加载状态下的按钮文字,默认值为空。 
vue
<template>
	<pure-button text="加载按钮" loading theme="primary"></pure-button>
	<pure-button text="加载按钮" loading loadingText="加载中" theme="success"></pure-button>
</template>按钮防抖 
- 通过 
debounce属性设置是否开启按钮防抖,默认值为true。 - 通过 
time属性设置防抖间隔,单位为毫秒,默认值为800。 - 通过 
tips属性设置触发防抖时的提示文字,默认值为空。 
vue
<template>
	<pure-button text="防抖按钮" debounce tips="请稍后再试" theme="primary"></pure-button>
</template>属性 
| 名称 | 类型 | 默认值 | 说明 | 
|---|---|---|---|
hoverClass | String | pure-hover | 按下去的样式类 | 
text | String | 按钮文字 | |
border | Boolean | false | 是否显示边框 | 
disabled | Boolean | false | 是否禁用 | 
theme | String | 按钮主题 | |
iconName | String | 前置图标名称 | |
iconOpts | Object | 前置图标选项 参考 | |
afterIconName | String | 后置图标名称 | |
afterIconOpts | Object | 后置图标选项 参考 | |
loading | Boolean | false | 加载状态 | 
loadingText | String | 加载状态文字 | |
loadingIconName | String | __loading | 加载状态图标名称 | 
loadingIconOpts | Object | 加载状态图标选项 参考 | |
ghost | Boolean | false | 是否幽灵按钮 | 
plain | Boolean | false | 是否镂空按钮 | 
shape | String | 按钮形状 | |
link | String | round | 按钮形状 | 
shape | String | round | 按钮形状 | 
block | Boolean | false | 是否块级按钮 | 
link | Boolean | false | 是否链接按钮 | 
underline | Boolean | false | 是否下划线按钮 | 
debounce | Boolean | true | 是否开启防抖 | 
time | Number | 800 | 防抖间隔时间,单位毫秒 | 
tips | String | 防抖提示文字 | |
openType | String | 开放能力 参考 | |
formType | String | 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件 参考 | |
hoverStartTime | Number | 20 | 按住后多久出现点击态,单位毫秒 参考 | 
hoverStayTime | Number | 70 | 手指松开后点击态保留时间,单位毫秒 参考 | 
appParameter | String | 打开 APP 时,向 APP 传递的参数 参考 | |
hoverStopPropagation | Boolean | false | 指定是否阻止本节点的祖先节点出现点击态 参考 | 
lang | String | zh-CN | 指定返回用户信息的语言 参考 | 
sessionFrom | String | 会话来源 参考 | |
sendMessageTitle | String | 会话内消息卡片标题 参考 | |
sendMessagePath | String | 会话内消息卡片点击跳转小程序路径 参考 | |
sendMessageImg | String | 会话内消息卡片图片 参考 | |
showMessageCard | String | 是否显示会话内消息卡片 参考 | |
groupId | String | 打开群资料卡时,传递的群号 参考 | |
guildId | String | 打开频道页面时,传递的频道号 参考 | |
publicId | String | 打开公众号资料卡时,传递的号码 参考 | |
dataImId | String | 客服的抖音号 参考 | |
dataImType | String | IM 卡片类型 参考 | |
dataGoodsId | String | 商品的 id 参考 | |
dataOrderId | String | 订单的 id 参考 | |
dataBizLine | String | 商品类型 参考 | |
scope | String | 支付宝小程序获取用户信息或获取用户手机号时,需同时设置此属性 参考 | 
事件 
| 名称 | 参数 | 说明 | 
|---|---|---|
onClick | 点击事件 | |
onDebounce | 防抖触发事件 | |
onGetPhoneNumber | event | 获取用户手机号回调 参考 | 
onGetUserInfo | event | 获取用户信息回调 参考 | 
onError | event | 当使用开放能力时,发生错误的回调 参考 | 
onOpenSetting | event | 在打开授权设置页并关闭后回调 参考 | 
onLaunchApp | event | 从小程序打开 App 成功的回调 参考 | 
onContact | event | 客服消息回调 参考 | 
onChooseAvatar | event | 获取用户头像回调 参考 | 
onAgreePrivacyAuthorization | event | 用户同意隐私协议事件回调 参考 | 
onAddGroupApp | event | 添加群应用的回调 参考 | 
onChooseAddress | event | 调起用户编辑并选择收货地址的回调 参考 | 
onChooseInvoiceTitle | event | 用户选择发票抬头的回调 参考 | 
onSubscribe | event | 订阅消息授权回调 参考 | 
onLogin | event | 登录回调 参考 | 
onIM | event | 监听跳转 IM 的成功回调 参考 | 
插槽 
| 名称 | 参数 | 说明 | 
|---|---|---|
#loading | 加载状态 | |
#loading-icon | 加载图标 | |
#loading-text | 加载提示文本 | |
#icon | 前置图标 | |
#default | 默认,按钮文本,按钮内容 | |
#after-icon | 后置图标 | 
样式变量 
| 名称 | 说明 | 
|---|---|
--pure-button-display | 布局类型 | 
--pure-button-margin | 内边距 | 
--pure-button-padding | 外边距 | 
--pure-button-font-size | 文本大小 | 
--pure-button-font-weight | 文本粗细 | 
--pure-button-color | 文本颜色 | 
--pure-button-width | 宽度 | 
--pure-button-height | 高度 | 
--pure-button-border-radius | 圆角大小 | 
--pure-button-line-height | 行高 | 
--pure-button-border | 边框样式 | 
--pure-button-border-width | 边框粗细 | 
--pure-button-border-style | 边框类型 | 
--pure-button-border-color | 边框颜色 | 
--pure-button-background | 背景 | 
--pure-button-background-opacity | 背景透明度 | 
--pure-button-gap | 按钮内容之间的间距 | 
--pure-button-icon-font-size | 图标文本大小 | 
--pure-button-icon-font-weight | 图标文本粗细 | 
--pure-button-icon-color | 图标文本颜色 | 
--pure-button-icon-margin | 图标外边距 | 
--pure-button-loading-icon-font-size | 加载图标文本大小 | 
--pure-button-loading-icon-font-weight | 加载图标文本粗细 | 
--pure-button-loading-icon-color | 加载图标文本颜色 | 
--pure-button-loading-icon-margin | 加载图标外边距 | 
--pure-button-front-icon-font-size | 前置图标文本大小 | 
--pure-button-front-icon-font-weight | 前置图标文本粗细 | 
--pure-button-front-icon-color | 前置图标文本颜色 | 
--pure-button-front-icon-margin | 前置图标外边距 | 
--pure-button-after-icon-font-size | 后置图标文本大小 | 
--pure-button-after-icon-font-weight | 后置图标文本粗细 | 
--pure-button-after-icon-color | 后置图标文本颜色 | 
--pure-button-after-icon-margin | 后置图标外边距 | 
--pure-button-loading-animation-duration | 加载图标转一圈所需的时间,单位毫秒 | 
--pure-button-loading-animation-timing-function | 加载图标的动画函数 | 
--pure-button-disabled-opacity | 禁用状态时的透明度 | 
--pure-button-underline-top | 下划线的布局 top 位置 | 
--pure-button-underline-bottom | 下划线的布局 bottom 位置 | 
--pure-button-underline-left | 下划线的布局 left 位置 | 
--pure-button-underline-right | 下划线的布局 right 位置 | 
--pure-button-underline-width | 下划线的宽度 | 
--pure-button-underline-height | 下划线的高度 | 
--pure-button-underline-color | 下划线的颜色 | 
--pure-button-underline-transform | 下划线的 transform 属性 |