|
@@ -8,7 +8,7 @@ const props = defineProps<{
|
|
|
modelValue: boolean
|
|
|
}>()
|
|
|
|
|
|
-const emit = defineEmits(['update:modelValue','finish'])
|
|
|
+const emit = defineEmits(['update:modelValue', 'finish'])
|
|
|
|
|
|
const cascaderValue = ref<string>() // 用于存储级联选择的值
|
|
|
const options = ref<CascaderOption[]>([]) // 用于存储级联选择的选项
|
|
@@ -25,14 +25,18 @@ const localShow = computed({
|
|
|
|
|
|
// 当弹窗关闭时触发事件,更新父组件的 areaShow
|
|
|
const onClose = () => {
|
|
|
+ cascaderValue.value = ''
|
|
|
emit('update:modelValue', false)
|
|
|
}
|
|
|
-
|
|
|
+const onClickOverlay = () => {
|
|
|
+ cascaderValue.value = ''
|
|
|
+}
|
|
|
|
|
|
// 当级联选择完成时
|
|
|
const onFinish = (value: any) => {
|
|
|
emit('update:modelValue', false)
|
|
|
- emit('finish',value)
|
|
|
+ emit('finish', value)
|
|
|
+ cascaderValue.value = ''
|
|
|
}
|
|
|
|
|
|
// 异步加载选项数据
|
|
@@ -60,7 +64,7 @@ onMounted(async () => {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <van-popup v-model:show="localShow" round position="bottom">
|
|
|
+ <van-popup v-model:show="localShow" @click-overlay="onClickOverlay" round position="bottom">
|
|
|
<van-cascader
|
|
|
v-model="cascaderValue"
|
|
|
title="请选择所在地区"
|