|
| 1 | +# Cube-Button 按钮 |
| 2 | + |
| 3 | +## 介绍 |
| 4 | + |
| 5 | +<card> |
| 6 | + |
| 7 | +操作按钮,提供了不同的样式、状态以及小程序的按钮功能,常用于触发一个点击操作。 |
| 8 | + |
| 9 | +</card> |
| 10 | + |
| 11 | +## 示例 |
| 12 | + |
| 13 | +<card> |
| 14 | + |
| 15 | +### 样式 |
| 16 | + |
| 17 | +除了默认样式外,可以通过设置 `primary`、`bolder` 、`outline`、`inline`、<!-- @theme: passenger -> start -->`light`<!-- @theme: passenger -> end -->属性来改变按钮的样子,也可以组合多重属性呈现不同的效果。 |
| 18 | + |
| 19 | +<!-- @group: btns -> start --> |
| 20 | + |
| 21 | +<!-- @example: btn-secondary -> template no-wrap --> |
| 22 | +<!-- @example: btn-primary -> template no-wrap --> |
| 23 | +<!-- @example: btn-bolder -> template no-wrap @code-block:name--> |
| 24 | +<!-- @example: btn-outline -> template no-wrap --> |
| 25 | +<!-- @example: btn-inline -> template no-wrap --> |
| 26 | +<!-- @example: btn-light -> template no-wrap --> |
| 27 | +<!-- @example: btn-outline-primary -> template no-wrap --> |
| 28 | +<!-- @example: btn-inline-outline -> template no-wrap --> |
| 29 | +<!-- @example: btn-inline-primary -> template no-wrap --> |
| 30 | +<!-- @example: btn-secondary-active -> template no-wrap @code-block:first--> |
| 31 | + |
| 32 | +<!-- @group: btns -> end --> |
| 33 | + |
| 34 | +</card> |
| 35 | + |
| 36 | +<card> |
| 37 | + |
| 38 | +### 状态 |
| 39 | + |
| 40 | +除了默认的正常状态,还可以设置激活、禁用<!-- @theme: passenger -> start -->以及加载中<!-- @theme: passenger -> end -->等状态。 |
| 41 | + |
| 42 | +<!-- @group: btns -> start --> |
| 43 | + |
| 44 | +<!-- @example: btn-secondary-active -> template no-wrap --> |
| 45 | +<!-- @example: btn-disabled -> template no-wrap --> |
| 46 | + |
| 47 | +<!-- @group: btns -> end --> |
| 48 | + |
| 49 | +<!-- @theme: passenger -> start --><!-- @example: btn-loading --><!-- @theme: passenger -> end --> |
| 50 | + |
| 51 | +</card> |
| 52 | + |
| 53 | +<card> |
| 54 | + |
| 55 | +### 图标<!-- @theme: passenger -> start -->、辅助文案<!-- @theme: passenger -> end --> |
| 56 | + |
| 57 | +可以设置 Icon 的 class,具体可以查看Icon demo。 |
| 58 | + |
| 59 | +<!-- @theme: passenger -> start -->可以设置 Tip 属性添加辅助文案。<!-- @theme: passenger -> end --> |
| 60 | + |
| 61 | +- With Icon 按钮 |
| 62 | +<!-- @example: btn-icon -> template no-wrap --> |
| 63 | + |
| 64 | +<!-- @theme: passenger -> start --> |
| 65 | +- With Tip 按钮 |
| 66 | +<!-- @example: btn-with-tip -> template no-wrap --> |
| 67 | +<!-- @theme: passenger -> end --> |
| 68 | + |
| 69 | +</card> |
| 70 | + |
| 71 | +<card> |
| 72 | + |
| 73 | +### 功能 |
| 74 | + |
| 75 | +可以通过设置 `openType`、`formType` 等属性,使用小程序的功能并绑定回调。详情参阅[微信 Button 文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)以及[支付宝 Button 文档](https://opendocs.alipay.com/mini/component/button)。使用方式如: |
| 76 | + |
| 77 | +- 分享(微信、支付宝) |
| 78 | +<!-- @example: btn-share -> template no-wrap --> |
| 79 | + |
| 80 | +- 获取用户手机号(微信、支付宝) |
| 81 | + |
| 82 | + 微信设置 `open-type` 为 `getPhoneNumber`;支付宝设置 ` open-type` 为 `getAuthorize`,设置 `scope` 为 `phoneNumber`。 |
| 83 | + |
| 84 | + 由于涉及用户隐私,手机号的获取需要满足一定的条件,详情参见[微信小程序获取手机号](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html)以及[支付宝小程序获取手机号](https://opendocs.alipay.com/mini/api/getphonenumber)。 |
| 85 | + |
| 86 | +<!-- @example: btn-get-phone-number -> template no-wrap --> |
| 87 | + |
| 88 | +- 获取用户信息(微信、支付宝) |
| 89 | + |
| 90 | + 微信设置 `open-type` 为 `getUserInfo`;支付宝设置 ` open-type` 为 `getAuthorize`,设置 `scope` 为 `userInfo`。 |
| 91 | + |
| 92 | + 功能使用有一定的限制,详情参见[支付宝小程序获取基础信息](https://opendocs.alipay.com/mini/api/ch8chh)。 |
| 93 | + |
| 94 | +<!-- @example: btn-get-user-info -> template no-wrap --> |
| 95 | + |
| 96 | +- 打开授权设置页面(微信、支付宝) |
| 97 | +<!-- @example: btn-open-setting -> template no-wrap --> |
| 98 | + |
| 99 | +- 打开客服会话(微信) |
| 100 | +<!-- @example: btn-contact -> template no-wrap --> |
| 101 | + |
| 102 | +- 获取用户头像(微信) |
| 103 | +<!-- @example: btn-choose-avatar -> template no-wrap --> |
| 104 | + |
| 105 | +- 打开 APP(微信) |
| 106 | +<!-- @example: btn-launch-app -> template no-wrap --> |
| 107 | + |
| 108 | +- 关注生活号(支付宝) |
| 109 | +<!-- @example: btn-follow-lifestyle -> template no-wrap --> |
| 110 | + |
| 111 | +</card> |
0 commit comments