fix(xispeak): JInput清空输入框时change事件不触发,修复emit顺序避免查询使用旧值

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wsm
2026-07-23 11:27:02 +08:00
co-authored by Claude Opus 4.7
parent 0fd3029105
commit d7ff8af059
@@ -1,5 +1,5 @@
<template>
<a-input v-bind="getBindValue" v-model:value="showText" @input="backValue"></a-input>
<a-input v-bind="getBindValue" v-model:value="showText" @input="backValue" @change="backValue"></a-input>
</template>
<script lang="ts">
@@ -23,6 +23,7 @@
const attrs = useAttrs();
//表单值
const showText = ref('');
let lastText = '';
// update-begin--author:liaozhiyang---date:20231026---for:【issues/803】JIput updateSchema不生效
//绑定属性
const getBindValue = computed(() => {
@@ -79,7 +80,7 @@
* 返回值
*/
function backValue(e) {
let text = e?.target?.value ?? '';
let text = typeof e === 'string' ? e : (e?.target?.value ?? '');
if (text && !!props.trim) {
text = text.trim();
}
@@ -98,8 +99,10 @@
break;
default:
}
emit('change', text);
if (text === lastText) return;
lastText = text;
emit('update:value', text);
emit('change', text);
}
return { showText, attrs, getBindValue, backValue };