初始化数据优化

This commit is contained in:
冯辉
2026-03-13 14:46:29 +08:00
parent 16ff0d1c4a
commit 2d5aca569a

View File

@@ -125,7 +125,7 @@
</template>
<script setup>
import { ref, reactive, onBeforeMount } from 'vue';
import { ref, reactive, onBeforeMount, watch } from 'vue';
import useDictStore from '@/stores/useDictStore';
const { getTransformChildren } = useDictStore();
@@ -174,12 +174,24 @@ const jobTypeOptions = ref([]);
const areaOptions = ref([]);
// 初始化获取数据
onBeforeMount(() => {
const initData = () => {
educationOptions.value = getTransformChildren('education', '学历要求').options || [];
experienceOptions.value = getTransformChildren('experience', '工作经验').options || [];
scaleOptions.value = getTransformChildren('scale', '公司规模').options || [];
jobTypeOptions.value = getJobTypeData();
areaOptions.value = getTransformChildren('area', '地区').options || [];
};
// 组件挂载时初始化数据
onBeforeMount(() => {
initData();
});
// 监听组件显示状态,当显示时重新初始化数据
watch(() => props.show, (newVal) => {
if (newVal) {
initData();
}
});
// 处理选项选择