Skip to content

Button 按钮

基本用法

基本按钮。

html
<wd-button>主要按钮</wd-button>
<wd-button type="success">成功按钮</wd-button>
<wd-button type="info">信息按钮</wd-button>
<wd-button type="warning">警告按钮</wd-button>
<wd-button type="error">危险按钮</wd-button>

禁用

设置 disabled 属性。

html
<wd-button disabled>默认按钮</wd-button>

幽灵按钮

设置 plain 属性。

html
<wd-button plain>主要按钮</wd-button>

细边框幽灵按钮

设置 hairline 属性。

html
<wd-button plain hairline>主要按钮</wd-button>

按钮大小

设置 size ,支持 'small'、'medium'、'large',默认为 'medium'。

html
<wd-button size="small">小号按钮</wd-button>
<wd-button size="medium">中号按钮</wd-button>
<wd-button size="large">大号按钮</wd-button>

加载中按钮

设置 loading 属性,让按钮处于加载中状态。加载中的按钮是禁止点击的。

html
<wd-button loading>加载中</wd-button>

文字按钮

type 设置为 text。文字按钮不支持其他颜色。

html
<wd-button type="text">文字按钮</wd-button>

图标按钮

type 设置为 icon,同时设置 icon 属性,icon为图标的类名,可以直接使用 Icon 图标 章节中的图标类名。

html
<wd-button type="icon" icon="menu"></wd-button>

带图标的按钮

设置 icon 属性,不需要设置 typeicon,即可以直接使用带图标的按钮。

html
<wd-button icon="edit-outline"></wd-button>

块状按钮

设置 block 属性。

html
<wd-button block>主要按钮</wd-button>

Attributes

参数说明类型可选值默认值最低版本
type按钮类型stringprimary / success / info / warning / error / text / iconprimary-
round圆角按钮boolean-true-
plain幽灵按钮boolean-false-
hairline是否细边框boolean-false-
loading加载中按钮boolean-false-
block块状按钮boolean-false-
size按钮尺寸stringsmall / medium / largemedium-
disabled禁用按钮boolean-false-
icon图标类名string---
loading-color加载图标颜色string---
open-type微信开放能力string---
form-type用于 form 组件,点击分别会触发 form 组件的 submit/reset 事件,该属性暂时不可用stringsubmit / reset--
hover-stop-propagation指定是否阻止本节点的祖先节点出现点击态boolean-false-
lang指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文stringzh_CN / zh_TWen-
session-from会话来源,open-type="contact"时有效string---
session-message-title会话内消息卡片标题,open-type="contact"时有效string-当前标题-
session-message-path会话内消息卡片点击跳转小程序路径,open-type="contact"时有效string-当前分享路径-
send-message-img会话内消息卡片图片,open-type="contact"时有效string-截图-
app-parameter打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效string---
show-message-card是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效boolean-false-

Events

事件名称说明参数最低版本
click点击事件--
getuserinfo获取用户信息--
contact客服消息回调,open-type="contact"时有效--
getphonenumber获取用户手机号回调,open-type=getPhoneNumber时有效--
error当使用开放能力时,发生错误的回调,open-type=launchApp时有效--
launchapp打开 APP 成功的回调,open-type=launchApp时有效--
opensetting在打开授权设置页后回调,open-type=openSetting时有效--

外部样式类

类名说明最低版本
custom-class根节点样式-

Released under the MIT License.

Released under the MIT License.