fix(xispeak): JInput清空输入框时change事件不触发,修复emit顺序避免查询使用旧值
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
//表单值
|
//表单值
|
||||||
const showText = ref('');
|
const showText = ref('');
|
||||||
|
let lastText = '';
|
||||||
// update-begin--author:liaozhiyang---date:20231026---for:【issues/803】JIput updateSchema不生效
|
// update-begin--author:liaozhiyang---date:20231026---for:【issues/803】JIput updateSchema不生效
|
||||||
//绑定属性
|
//绑定属性
|
||||||
const getBindValue = computed(() => {
|
const getBindValue = computed(() => {
|
||||||
@@ -79,7 +80,7 @@
|
|||||||
* 返回值
|
* 返回值
|
||||||
*/
|
*/
|
||||||
function backValue(e) {
|
function backValue(e) {
|
||||||
let text = e?.target?.value ?? '';
|
let text = typeof e === 'string' ? e : (e?.target?.value ?? '');
|
||||||
if (text && !!props.trim) {
|
if (text && !!props.trim) {
|
||||||
text = text.trim();
|
text = text.trim();
|
||||||
}
|
}
|
||||||
@@ -98,8 +99,10 @@
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
emit('change', text);
|
if (text === lastText) return;
|
||||||
|
lastText = text;
|
||||||
emit('update:value', text);
|
emit('update:value', text);
|
||||||
|
emit('change', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { showText, attrs, getBindValue, backValue };
|
return { showText, attrs, getBindValue, backValue };
|
||||||
|
|||||||
Reference in New Issue
Block a user