mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
fix: the handwritten keyboard does not trigger input change (#1200)
This commit is contained in:
parent
b46758c92f
commit
96c2a3af76
@ -16,5 +16,20 @@ Page({
|
|||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '点击图标'
|
title: '点击图标'
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onFieldChange({ detail }) {
|
||||||
|
console.log('change', detail);
|
||||||
|
this.setData({
|
||||||
|
sms: detail
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onFieldBlur({ detail }) {
|
||||||
|
console.log('blur', detail);
|
||||||
|
},
|
||||||
|
|
||||||
|
onSendSms() {
|
||||||
|
console.log('onSendSms', this.data.sms);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -81,8 +81,10 @@
|
|||||||
placeholder="请输入短信验证码"
|
placeholder="请输入短信验证码"
|
||||||
use-button-slot
|
use-button-slot
|
||||||
border="{{ false }}"
|
border="{{ false }}"
|
||||||
|
bind:change="onFieldChange"
|
||||||
|
bind:blur="onFieldBlur"
|
||||||
>
|
>
|
||||||
<van-button slot="button" size="small" type="primary" custom-class="button">发送验证码</van-button>
|
<van-button slot="button" size="small" type="primary" custom-class="button" bind:tap="onSendSms">发送验证码</van-button>
|
||||||
</van-field>
|
</van-field>
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
@ -76,8 +76,7 @@ VantComponent({
|
|||||||
value,
|
value,
|
||||||
showClear: this.getShowClear(value)
|
showClear: this.getShowClear(value)
|
||||||
}, () => {
|
}, () => {
|
||||||
this.$emit('input', value);
|
this.emitChange(value);
|
||||||
this.$emit('change', value);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -85,6 +84,7 @@ VantComponent({
|
|||||||
const { value = '', height = 0 } = event.detail || {};
|
const { value = '', height = 0 } = event.detail || {};
|
||||||
this.$emit('focus', { value, height });
|
this.$emit('focus', { value, height });
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
|
this.blurFromClear = false;
|
||||||
this.set({
|
this.set({
|
||||||
showClear: this.getShowClear()
|
showClear: this.getShowClear()
|
||||||
});
|
});
|
||||||
@ -94,9 +94,21 @@ VantComponent({
|
|||||||
const { value = '', cursor = 0 } = event.detail || {};
|
const { value = '', cursor = 0 } = event.detail || {};
|
||||||
this.$emit('blur', { value, cursor });
|
this.$emit('blur', { value, cursor });
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.set({
|
const showClear = this.getShowClear();
|
||||||
showClear: this.getShowClear()
|
|
||||||
});
|
if (this.data.value === value) {
|
||||||
|
this.set({
|
||||||
|
showClear
|
||||||
|
});
|
||||||
|
} else if (!this.blurFromClear) {
|
||||||
|
// fix: the handwritten keyboard does not trigger input change
|
||||||
|
this.set({
|
||||||
|
value,
|
||||||
|
showClear
|
||||||
|
}, () => {
|
||||||
|
this.emitChange(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickIcon() {
|
onClickIcon() {
|
||||||
@ -111,18 +123,23 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onClear() {
|
onClear() {
|
||||||
|
this.blurFromClear = true;
|
||||||
this.set({
|
this.set({
|
||||||
value: '',
|
value: '',
|
||||||
showClear: this.getShowClear('')
|
showClear: this.getShowClear('')
|
||||||
}, () => {
|
}, () => {
|
||||||
this.$emit('input', '');
|
this.emitChange('');
|
||||||
this.$emit('change', '');
|
|
||||||
this.$emit('clear', '');
|
this.$emit('clear', '');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onConfirm() {
|
onConfirm() {
|
||||||
this.$emit('confirm', this.data.value);
|
this.$emit('confirm', this.data.value);
|
||||||
|
},
|
||||||
|
|
||||||
|
emitChange(value) {
|
||||||
|
this.$emit('input', value);
|
||||||
|
this.$emit('change', value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user