代码拉取完成,页面将自动刷新
import {
onMounted,
onUpdated,
onUnmounted,
onBeforeMount,
onBeforeUpdate,
onBeforeUnmount,
onErrorCaptured,
onActivated,
onDeactivated,
} from "vue";
export function buildLifeCycle(contextWrap,configStd){
//
function registerLifeCycles() {
onMounted(() => invokeLifecycle("onMounted"));
onUpdated(() => invokeLifecycle("onUpdated"));
onUnmounted(() => invokeLifecycle("onUnmounted"));
onBeforeMount(() => invokeLifecycle("onBeforeMount"));
onBeforeUpdate(() => invokeLifecycle("onBeforeUpdate"));
onBeforeUnmount(() => invokeLifecycle("onBeforeUnmount"));
onActivated(() => invokeLifecycle("onActivated"));
onDeactivated(() => invokeLifecycle("onDeactivated"));
onErrorCaptured((err, instance, info) =>
invokeLifecycle("onErrorCaptured", err, instance, info)
);
}
//lifecycle
function invokeLifecycle(type: string, ...args) {
// console.log('**************'+type,contextWrap)
const handler = configStd.value["^" + type];
if (!handler) {
return;
}
if (Array.isArray(handler)) {
for (const single of handler) {
if (typeof single == "function") {
single(contextWrap, ...args);
} else {
throw Error("Unsuported handler for lifecycle:" + type + " in array");
}
}
} else if (typeof handler == "function") {
handler(contextWrap, ...args);
} else {
throw Error("Unsuported handler for lifecycle:" + type);
}
}
//
return registerLifeCycles
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。