1.5.1 • Published 1 year ago

@wines/button v1.5.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

@wines/button

Button 按钮

按钮组件用于响应用户点击行为,触发相应的业务逻辑,预设 9 种颜色 light, stable, positive, calm, assertive, balanced, energized, royal, dark 可选用。

使用指南

在 page.json 中引入组件

{
  "navigationBarTitleText": "Button",
  "usingComponents": {
    "wux-icon": "@wines/icon",
    "wux-button": "@wines/button"
  }
}

示例

目前,设置了 form-type 的 button 只会对当前组件中的 form 有效。因而,将 button 封装在自定义组件中,而 form 在自定义组件外,将会使这个 button 的 form-type 失效。

<view class="page">
	<view class="page__hd">
		<view class="page__title">Button</view>
		<view class="page__desc">按钮</view>
	</view>
	<view class="page__bd page__bd_spacing">
		<view class="sub-title">Type</view>
		<wux-button block type="light">light</wux-button>
		<wux-button block type="stable">stable</wux-button>
		<wux-button block type="positive">positive</wux-button>
		<wux-button block type="calm">calm</wux-button>
		<wux-button block type="assertive">assertive</wux-button>
		<wux-button block type="balanced">balanced</wux-button>
		<wux-button block type="energized">energized</wux-button>
		<wux-button block type="royal">royal</wux-button>
		<wux-button block type="dark">dark</wux-button>
		<view class="sub-title">Outline</view>
		<wux-button block outline type="light">light</wux-button>
		<wux-button block outline type="stable">stable</wux-button>
		<wux-button block outline type="positive">positive</wux-button>
		<wux-button block outline type="calm">calm</wux-button>
		<wux-button block outline type="assertive">assertive</wux-button>
		<wux-button block outline type="balanced">balanced</wux-button>
		<wux-button block outline type="energized">energized</wux-button>
		<wux-button block outline type="royal">royal</wux-button>
		<wux-button block outline type="dark">dark</wux-button>
		<view class="sub-title">Size</view>
		<wux-button block size="small" type="light">light</wux-button>
		<wux-button block size="small" type="stable">stable</wux-button>
		<wux-button block size="small" type="positive">positive</wux-button>
		<wux-button block size="default" type="calm">calm</wux-button>
		<wux-button block size="default" type="assertive">assertive</wux-button>
		<wux-button block size="default" type="balanced">balanced</wux-button>
		<wux-button block size="large" type="energized">energized</wux-button>
		<wux-button block size="large" type="royal">royal</wux-button>
		<wux-button block size="large" type="dark">dark</wux-button>
		<view class="sub-title">Clear</view>
		<wux-button block clear type="light">light</wux-button>
		<wux-button block clear type="stable">stable</wux-button>
		<wux-button block clear type="positive">positive</wux-button>
		<wux-button block clear type="calm">calm</wux-button>
		<wux-button block clear type="assertive">assertive</wux-button>
		<wux-button block clear type="balanced">balanced</wux-button>
		<wux-button block clear type="energized">energized</wux-button>
		<wux-button block clear type="royal">royal</wux-button>
		<wux-button block clear type="dark">dark</wux-button>
		<view class="sub-title">Loading</view>
		<wux-button block loading type="light">light</wux-button>
		<wux-button block loading type="stable">stable</wux-button>
		<wux-button block loading type="positive">positive</wux-button>
		<wux-button block loading type="calm">calm</wux-button>
		<wux-button block loading type="assertive">assertive</wux-button>
		<wux-button block loading type="balanced">balanced</wux-button>
		<wux-button block loading type="energized">energized</wux-button>
		<wux-button block loading type="royal">royal</wux-button>
		<wux-button block loading type="dark">dark</wux-button>
		<view class="sub-title">Disabled</view>
		<wux-button block disabled type="light">light</wux-button>
		<wux-button block disabled type="stable">stable</wux-button>
		<wux-button block disabled type="positive">positive</wux-button>
		<wux-button block disabled type="calm">calm</wux-button>
		<wux-button block disabled type="assertive">assertive</wux-button>
		<wux-button block disabled type="balanced">balanced</wux-button>
		<wux-button block disabled type="energized">energized</wux-button>
		<wux-button block disabled type="royal">royal</wux-button>
		<wux-button block disabled type="dark">dark</wux-button>
		<view class="sub-title">Icon</view>
		<wux-button block type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
		<wux-button block outline type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
		<wux-button block size="small" type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
		<wux-button block size="default" type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
		<wux-button block size="large" type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
		<wux-button block clear type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
		<wux-button block disabled type="balanced">
			<wux-icon type="ios-save" size="16" />
			balanced
		</wux-button>
	</view>
</view>

API

Button props

参数类型描述默认值
prefixClsstring自定义类名前缀wux-button
typestring按钮类型,可选值为 light、stable、positive、calm、assertive、balanced、energized、royal、darkstable
clearboolean是否清除样式false
blockboolean是否块级元素false
fullboolean是否通栏false
outlineboolean是否镂空false
borderedboolean是否带边框true
sizestring按钮的大小,可选值为 small、default、largedefault
disabledboolean是否禁用false
loadingboolean名称前是否带 loading 图标false
formTypestring用于 <form/> 组件,点击分别会触发 <form/> 组件的 submit/reset 事件-
openTypestring微信开放能力,可选值为 contact、share、getUserInfo、getPhoneNumber-
hoverClassstring指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果default
hoverStopPropagationboolean指定是否阻止本节点的祖先节点出现点击态false
hoverStartTimenumber按住后多久出现点击态,单位毫秒20
hoverStayTimenumber手指松开后点击态保留时间,单位毫秒70
langstring指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。en
sessionFromstring会话来源-
sendMessageTitlestring会话内消息卡片标题当前标题
sendMessagePathstring会话内消息卡片点击跳转小程序路径当前分享路径
sendMessageImgstring会话内消息卡片图片截图
showMessageCardboolean显示会话内消息卡片false
appParameterstring打开 APP 时,向 APP 传递的参数-
bind:clickfunction点击事件-
bind:getuserinfofunction用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与wx.getUserInfo返回的一致-
bind:contactfunction客服消息回调-
bind:getphonenumberfunction获取用户手机号回调-
bind:errorfunction当使用开放能力时,发生错误的回调-
bind:opensettingfunction在打开授权设置页后回调-

更多参数说明请参考微信官方的表单组件 Button

Button slot

名称描述
-自定义内容

Button externalClasses

名称描述
wux-class根节点样式类
wux-hover-class按钮按下去的样式类