|
2 | 2 |
|
3 | 3 | # Button 按钮 |
4 | 4 |
|
5 | | - |
6 | 5 | ## 基本用法 |
7 | 6 |
|
8 | 7 | 基本按钮。 |
|
39 | 38 | <wd-button plain hairline>主要按钮</wd-button> |
40 | 39 | ``` |
41 | 40 |
|
42 | | - |
43 | 41 | ## 按钮大小 |
44 | 42 |
|
45 | 43 | 设置 `size` ,支持 'small'、'medium'、'large',默认为 'medium'。 |
|
68 | 66 |
|
69 | 67 | ## 图标按钮 |
70 | 68 |
|
71 | | -将 `type` 设置为 `icon`,同时设置 `icon` 属性,icon为图标的类名,可以直接使用 `Icon 图标` 章节中的图标类名。 |
| 69 | +将 `type` 设置为 `icon`,同时设置 `icon` 属性,icon 为图标的类名,可以直接使用 `Icon 图标` 章节中的图标类名。 |
72 | 70 |
|
73 | 71 | ```html |
74 | 72 | <wd-button type="icon" icon="picture"></wd-button> |
|
83 | 81 | ``` |
84 | 82 |
|
85 | 83 | 结合`classPrefix`可以使用自定义图标,参见 [Icon 自定义图标](/component/icon#自定义图标)。 |
| 84 | + |
86 | 85 | ```html |
87 | 86 | <wd-button classPrefix="fish" icon="kehuishouwu">可回收</wd-button> |
88 | 87 | ``` |
|
95 | 94 | <wd-button block>主要按钮</wd-button> |
96 | 95 | ``` |
97 | 96 |
|
| 97 | +## 自定义样式 |
| 98 | + |
| 99 | +通过 `custom-class` 和 `custom-style` 属性可以自定义按钮的样式,这里我们使用`custom-class`给按钮添加一个 `Material Design 3` 风格的`box-shadow`。 |
| 100 | + |
| 101 | +```html |
| 102 | +<view class="page-class"> |
| 103 | + <wd-button custom-class="custom-shadow">主要按钮</wd-button> |
| 104 | + <wd-button type="success" custom-class="custom-shadow">成功按钮</wd-button> |
| 105 | + <wd-button type="info" custom-class="custom-shadow">信息按钮</wd-button> |
| 106 | + <wd-button type="warning" custom-class="custom-shadow">警告按钮</wd-button> |
| 107 | + <wd-button type="error" custom-class="custom-shadow">危险按钮</wd-button> |
| 108 | +</view> |
| 109 | +``` |
| 110 | + |
| 111 | +```scss |
| 112 | +.page-class { |
| 113 | + :deep() { |
| 114 | + .custom-shadow { |
| 115 | + box-shadow: 0 3px 1px -2px rgb(0 0 0 / 20%), 0 2px 2px 0 rgb(0 0 0 / 14%), 0 1px 5px 0 rgb(0 0 0 / 12%); |
| 116 | + } |
| 117 | + } |
| 118 | +} |
| 119 | +``` |
| 120 | + |
98 | 121 | ## Attributes |
99 | 122 |
|
100 | | -| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 | |
101 | | -|-----|------|-----|-------|-------|--------| |
102 | | -| type | 按钮类型 | string | primary / success / info / warning / error / text / icon | primary | - | |
103 | | -| round | 圆角按钮 | boolean | - | true | - | |
104 | | -| plain | 幽灵按钮 | boolean | - | false | - | |
105 | | -| hairline| 是否细边框 | boolean | - | false | - | |
106 | | -| loading | 加载中按钮 | boolean | - | false | - | |
107 | | -| block | 块状按钮 | boolean | - | false | - | |
108 | | -| size | 按钮尺寸 | string | small / medium / large | medium | - | |
109 | | -| disabled | 禁用按钮 | boolean | - | false | - | |
110 | | -| icon | 图标类名 | string | - | - | - | |
111 | | -| loading-color | 加载图标颜色 | string | - | - | - | |
112 | | -| open-type | 微信开放能力 | string | - | - | - | |
113 | | -| hover-stop-propagation | 指定是否阻止本节点的祖先节点出现点击态 | boolean | - | false | - | |
114 | | -| lang | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文 | string | zh_CN / zh_TW | en | - | |
115 | | -| session-from | 会话来源,open-type="contact"时有效 | string | - | - | - | |
116 | | -| session-message-title | 会话内消息卡片标题,open-type="contact"时有效 | string | - | 当前标题 | - | |
117 | | -| session-message-path | 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 | string | - | 当前分享路径 | - | |
118 | | -| send-message-img | 会话内消息卡片图片,open-type="contact"时有效 | string | - | 截图 | - | |
119 | | -| app-parameter | 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | string | - | - | - | |
120 | | -| show-message-card | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 | boolean | - | false | - | |
121 | | -| classPrefix | 类名前缀,用于使用自定义图标,参见[icon](/component/icon#自定义图标) | string | - | 'wd-icon' | 0.1.27 | |
122 | | -| button-id | 按钮的唯一标识,可用于设置隐私同意授权按钮的id | string | - | - | 1.3.6 | |
123 | | -| scope | 支付宝小程序使用,当 open-type 为 getAuthorize 时有效。 | ButtonScope | `phoneNumber` / `userInfo` | - | 1.3.14 | |
| 123 | +| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 | |
| 124 | +| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------- | ------------ | -------- | |
| 125 | +| type | 按钮类型 | string | primary / success / info / warning / error / text / icon | primary | - | |
| 126 | +| round | 圆角按钮 | boolean | - | true | - | |
| 127 | +| plain | 幽灵按钮 | boolean | - | false | - | |
| 128 | +| hairline | 是否细边框 | boolean | - | false | - | |
| 129 | +| loading | 加载中按钮 | boolean | - | false | - | |
| 130 | +| block | 块状按钮 | boolean | - | false | - | |
| 131 | +| size | 按钮尺寸 | string | small / medium / large | medium | - | |
| 132 | +| disabled | 禁用按钮 | boolean | - | false | - | |
| 133 | +| icon | 图标类名 | string | - | - | - | |
| 134 | +| loading-color | 加载图标颜色 | string | - | - | - | |
| 135 | +| open-type | 微信开放能力 | string | - | - | - | |
| 136 | +| hover-stop-propagation | 指定是否阻止本节点的祖先节点出现点击态 | boolean | - | false | - | |
| 137 | +| lang | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文 | string | zh_CN / zh_TW | en | - | |
| 138 | +| session-from | 会话来源,open-type="contact"时有效 | string | - | - | - | |
| 139 | +| session-message-title | 会话内消息卡片标题,open-type="contact"时有效 | string | - | 当前标题 | - | |
| 140 | +| session-message-path | 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 | string | - | 当前分享路径 | - | |
| 141 | +| send-message-img | 会话内消息卡片图片,open-type="contact"时有效 | string | - | 截图 | - | |
| 142 | +| app-parameter | 打开 APP 时,向 APP 传递的参数,open-type=launchApp 时有效 | string | - | - | - | |
| 143 | +| show-message-card | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 | boolean | - | false | - | |
| 144 | +| classPrefix | 类名前缀,用于使用自定义图标,参见[icon](/component/icon#自定义图标) | string | - | 'wd-icon' | 0.1.27 | |
| 145 | +| button-id | 按钮的唯一标识,可用于设置隐私同意授权按钮的 id | string | - | - | 1.3.6 | |
| 146 | +| scope | 支付宝小程序使用,当 open-type 为 getAuthorize 时有效。 | ButtonScope | `phoneNumber` / `userInfo` | - | 1.3.14 | |
124 | 147 |
|
125 | 148 | ### ButtonOpenType 开放能力 |
126 | 149 |
|
|
141 | 164 |
|
142 | 165 | ## Events |
143 | 166 |
|
144 | | -| 事件名称 | 说明 | 参数 | 最低版本 | |
145 | | -|---------|-----|-----|---------| |
146 | | -| click | 点击事件 | `event` | - | |
147 | | -| getuserinfo | 获取用户信息 | `detail` | - | |
148 | | -| contact | 客服消息回调,open-type="contact"时有效 | `detail` | - | |
149 | | -| getphonenumber | 获取用户手机号回调,open-type=getPhoneNumber时有效 | `detail` | - | |
150 | | -| error | 当使用开放能力时,发生错误的回调,open-type=launchApp时有效 | `detail` | - | |
151 | | -| launchapp | 打开 APP 成功的回调,open-type=launchApp时有效 | `detail` | - | |
152 | | -| opensetting | 在打开授权设置页后回调,open-type=openSetting时有效 | `detail` | - | |
| 167 | +| 事件名称 | 说明 | 参数 | 最低版本 | |
| 168 | +| -------------- | ------------------------------------------------------------ | -------- | -------- | |
| 169 | +| click | 点击事件 | `event` | - | |
| 170 | +| getuserinfo | 获取用户信息 | `detail` | - | |
| 171 | +| contact | 客服消息回调,open-type="contact"时有效 | `detail` | - | |
| 172 | +| getphonenumber | 获取用户手机号回调,open-type=getPhoneNumber 时有效 | `detail` | - | |
| 173 | +| error | 当使用开放能力时,发生错误的回调,open-type=launchApp 时有效 | `detail` | - | |
| 174 | +| launchapp | 打开 APP 成功的回调,open-type=launchApp 时有效 | `detail` | - | |
| 175 | +| opensetting | 在打开授权设置页后回调,open-type=openSetting 时有效 | `detail` | - | |
153 | 176 |
|
154 | 177 | ## 外部样式类 |
155 | 178 |
|
156 | | -| 类名 | 说明 | 最低版本 | |
157 | | -|-----|------|--------| |
158 | | -| custom-class | 根节点样式 | - | |
| 179 | +| 类名 | 说明 | 最低版本 | |
| 180 | +| ------------ | ---------- | -------- | |
| 181 | +| custom-class | 根节点样式 | - | |
0 commit comments