generated from Leo_Ding/web-template
优化所在区域数据加载有时不显示的问题
This commit is contained in:
parent
aadd779cda
commit
7b65c5e27f
@ -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
|
||||
// });
|
||||
|
||||
|
||||
// 异步加载子节点(市、区)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user