0.0.18 • Published 3 years ago

@retailwe/ui-button v0.0.18

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

button 按钮

引入

全局引入,在 miniprogram 根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。

// app.json 或 index.json
"usingComponents": {
  "wr-button": "@retailwe/ui-button/index"
}

代码演示

基本用法

按钮类型

<wr-button>默认按钮</wr-button>
<wr-button type="primary">主要按钮</wr-button>
<wr-button type="disabled">禁用按钮</wr-button>

按钮尺寸

<wr-button type="primary" size="small">小型按钮</wr-button>
<wr-button type="primary">普通按钮</wr-button>
<wr-button type="primary" size="large">大号按钮</wr-button>

按钮边框

<wr-button>普通按钮</wr-button>
<wr-button hairline>细边框按钮</wr-button>
<wr-button no-border>无边框按钮</wr-button>

加载状态

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

图标按钮

<wr-button type="primary">
  <wr-icon name="home"></wr-icon>
</wr-button>
<wr-button no-border>
  <image mode="widthFix"
    src="https://cdn-we-retail.ym.tencent.com/miniapp/home/home-default-logo.png"
    style="width: 100rpx; padding: 15rpx 0;">
  </image>
</wr-button>

块级元素(占满整行)

<view>
  <wr-button type="primary">普通按钮</wr-button>
</view>
<view style="margin-top: 20rpx">
  <wr-button type="primary" block>块级元素</wr-button>
</view>

自定义样式

<wr-button btn-style="background-color: white; color: #7232dd;">单色按钮</wr-button>
<wr-button btn-style="background-color: #7232dd; color: white;">单色按钮</wr-button>
<wr-button btn-style="background: linear-gradient(to right, #4bb0ff, #6149f6); color: white;">渐变色按钮</wr-button>

使用小程序开放能力

<wr-button size="small" open-type="getUserInfo" bindgetuserinfo="handdleGetUserInfo">获取用户信息</wr-button>
<wr-button size="small" open-type="getPhoneNumber" bindgetphonenumber="handdleGetPhoneNumber">获取手机号</wr-button>
<wr-button size="small" open-type="share">分享</wr-button>
Page({
  data: {},
  handdleGetUserInfo(e: any) {
    console.log('e', e);
    console.log(e.detail.errMsg);
    console.log(e.detail.iv);
    console.log(e.detail.encryptedData);
  },
  handdleGetPhoneNumber(e: any) {
    console.log('e', e);
    console.log(e.detail.errMsg);
    console.log(e.detail.iv);
    console.log(e.detail.encryptedData);
  },
  onShareAppMessage(e: any) {
    console.log('e', e);
    return {
      title: 'button',
      path: 'components-exp/button/index',
    };
  },
});

button Props

参数说明类型默认值版本
type按钮样式类型stringnormal-
size按钮尺寸类型stringmiddle-
hairline是否显示窄边框,通过缩放实现booleanfalse
noBorder不显示边框booleanfalse
block按钮是否自动占满整行booleanfalse
text按钮文字,text为空时可使用slotstring-
btnStyle透传给按钮的样式string-
loading透传给原生button的属性boolean-
disabled透传给原生button的属性boolean-
openType透传给原生button的属性string-
businessId透传给原生button的属性number-
sessionFrom透传给原生button的属性string-
sendMessageTitle透传给原生button的属性string-
sendMessagePath透传给原生button的属性string-
sendMessageImg透传给原生button的属性string-
showMessageCard透传给原生button的属性boolean-
appParameter透传给原生button的属性string-

button Event

事件名说明参数
click点击按钮触发-
click-disabled已禁用按钮被点击时触发-
getuserinfo透传来自原生button的事件
contact透传来自原生button的事件
getphonenumber透传来自原生button的事件
error透传来自原生button的事件
launchapp透传来自原生button的事件
opensetting透传来自原生button的事件

Slots

名称说明
-按钮文字或图片等

empty 外部样式类

类名说明
wr-class根节点样式类
0.0.18

3 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7-beta.1

4 years ago