分区-公共组件select-afterInit钩子
This commit is contained in:
@@ -49,6 +49,10 @@ export default {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
afterInit: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
}
|
||||
},
|
||||
// 明确声明触发的事件
|
||||
emits: ["update:partitionId", "update:partitionInfos"],
|
||||
@@ -57,7 +61,6 @@ export default {
|
||||
const partitionInfoList = ref(props.partitionInfos);
|
||||
// 定义响应式变量 internalValue 用于内部管理 partitionId 的值
|
||||
const partitionIdValue = ref(props.partitionId);
|
||||
const handleChangeFunc = ref(props.handleChange);
|
||||
|
||||
// 监听外部传入的 partitionId 变化,并同步到 internalValue
|
||||
watch(
|
||||
@@ -72,6 +75,8 @@ export default {
|
||||
const listDateFunc = !props.needAllPartition? getPartitionInfoList: listAll;
|
||||
listDateFunc().then((res) => {
|
||||
setPartitionInfos(res.data)
|
||||
}).finally(() => {
|
||||
props.afterInit()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,7 +101,7 @@ export default {
|
||||
partitionIdValue.value = value
|
||||
emit("update:partitionId", value);
|
||||
|
||||
handleChangeFunc.value(value);
|
||||
props.handleChange(value);
|
||||
};
|
||||
|
||||
// 返回需要暴露给模板使用的变量和方法
|
||||
|
Reference in New Issue
Block a user