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