UNPKG

antd-mini

Version:

antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。

24 lines (23 loc) 932 B
import isFunction from 'lodash.isfunction'; import { Component, getValueFromProps, triggerEvent } from '../_util/simply'; import { componentsProps } from './props'; Component(componentsProps, { getCurTapVoucher: function (event) { var index = event.currentTarget.dataset.index; var dataSource = getValueFromProps(this, 'dataSource'); return dataSource[index]; }, handleVoucherTap: function (e) { triggerEvent(this, 'voucherTap', this.getCurTapVoucher(e), e); }, handleBtnTap: function (e) { var voucher = this.getCurTapVoucher(e); var _a = getValueFromProps(this, ['onBtnTap', 'onTap']), onBtnTap = _a[0], onTap = _a[1]; if (isFunction(onBtnTap)) { triggerEvent(this, 'btnTap', voucher, e); } else if (isFunction(onTap)) { triggerEvent(this, 'tap', voucher, e); } }, }, undefined, undefined, undefined);