var b = function(e) { !function(e, t) { if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && p(e, t) }(l, e); var b = function (e) { function l(e) { var t; return function (e, t) { if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") }(this, l), (t = y.call(this, e)).resend = function () { if (t.state.waiting) return !1; var e = t.props.mobile; return (0, c.getSMSCode)({ mobile: e, sendType: 1 }).then((function () { t.setState({ text: '发送成功', waiting: !0 }); setTimeout(function () { t.setState({ text: '重新发送', waiting: !1 }); }, 5000); })).catch((function () { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {} , n = e.message; n && a.default.info(n); t.setState({ text: '重新发送', waiting: !1 }); })), !0 } , t.state = { waiting: !1, text: '发送验证码' }, t } return s(l, e), i(l, [{ key: 'render', value: function () { return o.default.createElement('div', { className: 'code-btn', onClick: this.resend }, this.state.text); } }]), l }(o.Component);

var v = b;
t.default = v;

}; e.exports = b;

React 发送验证码组件 - 无计时器版本

原文地址: https://www.cveoy.top/t/topic/lHHX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录