diff --git a/src/components/AreaCascader/index.vue b/src/components/AreaCascader/index.vue index b13f364..d4a4d58 100644 --- a/src/components/AreaCascader/index.vue +++ b/src/components/AreaCascader/index.vue @@ -53,10 +53,19 @@ const emit = defineEmits(['change']); // 本地选项数据(初始为空,异步加载) const options = ref([]); -onMounted(() => { - // 使用 store 中的省份数据 - options.value = dicsStore.provinceOptions -}); +watch( + () => dicsStore.provinceOptions, + (newVal) => { + if (newVal && newVal.length > 0) { + options.value = newVal + } + }, + { immediate: true } // 🔥 关键:组件初始化时也会执行一次 +) +// onMounted(async () => { +// // 使用 store 中的省份数据 +// options.value = await dicsStore.provinceOptions +// }); // 异步加载子节点(市、区)