浏览代码

[ui] Vue 3 - Foxed callHooks in wrapper utils

sreenaths 4 年之前
父节点
当前提交
91864e7300
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      desktop/core/src/desktop/js/vue/wrapper/utils.ts

+ 5 - 2
desktop/core/src/desktop/js/vue/wrapper/utils.ts

@@ -27,9 +27,12 @@ export function injectHook (options: KeyHash, key: string, hook: Function) {
 
 export function callHooks (vm: ComponentPublicInstance | undefined, hook: string) {
   if (vm) {
-    const hooks = vm.$options[hook] || [];
+    let hooks = vm.$options[hook] || [];
+    if(!Array.isArray(hooks)) {
+      hooks = [hooks];
+    }
     hooks.forEach((hook: Function) => {
-      hook.call(vm)
+      hook.call(vm);
     });
   }
 }