Yao d2ef7fbc03
[breaking change] Field: 修复组件错误的事件参数 (#391)
* 优化编译脚本,在预览时降低编译频率

* 修复 field 事件传参

* 降低等待事件
2018-07-30 11:44:25 +08:00

70 lines
1.2 KiB
JavaScript

Component({
behaviors: ['wx://form-field'],
externalClasses: ['field-class'],
relations: {
'../cell-group/index': {
type: 'parent'
}
},
properties: {
title: String,
type: {
type: String,
value: 'input'
},
disabled: Boolean,
focus: Boolean,
inputType: {
type: String,
value: 'text'
},
placeholder: String,
mode: {
type: String,
value: 'normal'
},
right: Boolean,
error: Boolean,
maxlength: {
type: Number,
value: 140
}
},
data: {
showBorder: true
},
methods: {
handleFieldChange(event) {
const { detail = {} } = event;
const { value = '' } = detail;
this.setData({ value });
this.triggerEvent('change', { ...detail });
},
handleFieldFocus({ detail = {} }) {
this.triggerEvent('focus', { ...detail });
},
handleFieldBlur({ detail = {} }) {
this.triggerEvent('blur', { ...detail });
},
updateIsLastElement(isLastField) {
let showBorder = true;
if (isLastField && this.data.mode === 'normal') {
showBorder = false;
}
this.setData({
showBorder
});
}
}
});