修改
This commit is contained in:
@ -194,6 +194,10 @@ const props = defineProps({
|
||||
inline:{
|
||||
type:Boolean,
|
||||
default:true
|
||||
},
|
||||
disabled:{
|
||||
type:Boolean,
|
||||
default:false
|
||||
}
|
||||
});
|
||||
const elform = ref();
|
||||
@ -214,18 +218,25 @@ const reset = () =>{
|
||||
elform.value.resetFields()
|
||||
}
|
||||
|
||||
// 修改这里的watch逻辑,避免无限循环
|
||||
let isUpdatingFromProps = false;
|
||||
|
||||
watch(() => listQuery.value,(newVal) => {
|
||||
if(newVal) emits("update:modelValue", newVal);
|
||||
},{ immediate: true, deep: true });
|
||||
if(newVal && !isUpdatingFromProps) {
|
||||
emits("update:modelValue", newVal);
|
||||
}
|
||||
},{ deep: true });
|
||||
|
||||
watch(() => props.modelValue,(newVal) => {
|
||||
// 只有在新值确实变化时才更新(避免空值覆盖)
|
||||
if (newVal && Object.keys(newVal).length > 0) {
|
||||
isUpdatingFromProps = true;
|
||||
listQuery.value = { ...newVal };
|
||||
setTimeout(() => {
|
||||
isUpdatingFromProps = false;
|
||||
}, 0);
|
||||
}
|
||||
},{ immediate: true, deep: true });
|
||||
|
||||
|
||||
|
||||
defineExpose({ submit,reset });
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user