[Improvement] Icon: add tap event

This commit is contained in:
陈嘉涵 2018-07-31 14:34:17 +08:00
parent f17a09419f
commit ef279ded3a
5 changed files with 10 additions and 3 deletions

View File

@ -78,7 +78,7 @@
| 事件名 | 说明 | 参数 | | 事件名 | 说明 | 参数 |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| click | 点击按钮且按钮状态不为加载或禁用时触发 | - | | tap | 点击按钮且按钮状态不为加载或禁用时触发 | - |
| getuserinfo | 用户点击该按钮时,会返回获取到的用户信息,从返回参数的 detail 中获取到的值同 wx.getUserInfo | - | | getuserinfo | 用户点击该按钮时,会返回获取到的用户信息,从返回参数的 detail 中获取到的值同 wx.getUserInfo | - |
| contact | 客服消息回调 | - | | contact | 客服消息回调 | - |
| getphonenumber | 获取用户手机号回调 | - | | getphonenumber | 获取用户手机号回调 | - |

View File

@ -53,7 +53,7 @@ Component({
methods: { methods: {
onTap(event) { onTap(event) {
if (!this.data.disabled && !this.data.loading) { if (!this.data.disabled && !this.data.loading) {
this.triggerEvent('click', event); this.triggerEvent('tap', event);
} }
}, },

View File

@ -32,7 +32,7 @@
| 事件名 | 说明 | 参数 | | 事件名 | 说明 | 参数 |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| click | 点击图标时触发 | - | | tap | 点击图标时触发 | - |
### 外部样式类 ### 外部样式类

View File

@ -6,5 +6,11 @@ Component({
name: String, name: String,
size: String, size: String,
color: String color: String
},
methods: {
onTap(event) {
this.triggerEvent('tap', event);
}
} }
}); });

View File

@ -1,6 +1,7 @@
<view <view
class="custom-class van-icon van-icon-{{ name }}" class="custom-class van-icon van-icon-{{ name }}"
style="{{ color ? 'color: ' + color : '' }}; {{ size ? 'font-size: ' + size : '' }}" style="{{ color ? 'color: ' + color : '' }}; {{ size ? 'font-size: ' + size : '' }}"
bind:tap="onTap"
> >
<view wx:if="{{ info !== null }}" class="van-icon__info">{{ info }}</view> <view wx:if="{{ info !== null }}" class="van-icon__info">{{ info }}</view>
</view> </view>