antd-mini
Version:
antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。
32 lines (31 loc) • 1.17 kB
JavaScript
import { Component, getValueFromProps, triggerEvent } from '../_util/simply';
import { PostscriptProps } from './props';
Component({
props: PostscriptProps,
data: {
content: '',
},
methods: {
checkMaxLength: function (value) {
var maxLength = Number(getValueFromProps(this, 'maxLength') || -1);
if (maxLength !== -1 && value.length > maxLength) {
return value.slice(0, maxLength);
}
return value;
},
handleInput: function (val) {
var value = val;
this.setData({ content: value });
triggerEvent(this, 'change', value);
},
handleQuickInput: function (e) {
var value = e.currentTarget.dataset.value;
var combineSymbol = getValueFromProps(this, 'combineSymbol');
var result = this.checkMaxLength(combineSymbol
? "".concat(this.data.content ? "".concat(this.data.content).concat(combineSymbol) : '').concat(value)
: value);
this.setData({ content: result });
triggerEvent(this, 'change', result);
},
},
});