diff --git a/src/components/MoneyManage/ProductSelect.vue b/src/components/MoneyManage/ProductSelect.vue index 234eb33..cd25c82 100644 --- a/src/components/MoneyManage/ProductSelect.vue +++ b/src/components/MoneyManage/ProductSelect.vue @@ -244,17 +244,30 @@ const clickmenu = (index) => { activeIndex.value = activeIndex.value === index ? -1 : index; } +const resetSelect = () => { + selectedValue.value = ''; // 重置选中值 + selectedItem.value = ''; // 重置显示文本 + isOpen.value = false; // 关闭下拉菜单 + coinisOpen.value = false; // 关闭金币产品子菜单 + productisOpen.value = false; // 关闭软件产品子菜单 + activeIndex.value = -1; // 关闭二级菜单 +}; + watch(() => props.modelValue, (newVal) => { selectedItem.value = newVal; + selectedValue.value = newVal; }, { immediate: true }); onMounted(async () => { + console.log('打开组件', props.modelValue); selectedValue.value = props.modelValue; selectedItem.value = selectedValue.value || ''; document.addEventListener('click', handleGlobalClick); // 绑定全局事件 }); onUnmounted(() => { + selectedValue.value = ''; document.removeEventListener('click', handleGlobalClick); // 解绑全局事件 }); +defineExpose({ resetSelect });