mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
70 lines
1.1 KiB
JavaScript
70 lines
1.1 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', event);
|
|
},
|
|
|
|
handleFieldFocus(event) {
|
|
this.triggerEvent('focus', event);
|
|
},
|
|
|
|
handleFieldBlur(event) {
|
|
this.triggerEvent('blur', event);
|
|
},
|
|
|
|
updateIsLastElement(isLastField) {
|
|
let showBorder = true;
|
|
if (isLastField && this.data.mode === 'normal') {
|
|
showBorder = false;
|
|
}
|
|
|
|
this.setData({
|
|
showBorder
|
|
});
|
|
}
|
|
}
|
|
});
|