[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 | - |
| contact | 客服消息回调 | - |
| getphonenumber | 获取用户手机号回调 | - |

View File

@ -53,7 +53,7 @@ Component({
methods: {
onTap(event) {
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,
size: String,
color: String
},
methods: {
onTap(event) {
this.triggerEvent('tap', event);
}
}
});

View File

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