From 2bea8cd73dc6f405db65ca579c9eb2b19cb07c95 Mon Sep 17 00:00:00 2001 From: icssoa <2570063477@qq.com> Date: Thu, 23 Mar 2023 11:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E6=97=A0=E6=B3=95=E8=87=AA=E5=8A=A8=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cool/bootstrap/module.ts | 32 +++++++++++++--------------- src/modules/demo/directives/color.ts | 5 +++++ 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 src/modules/demo/directives/color.ts diff --git a/src/cool/bootstrap/module.ts b/src/cool/bootstrap/module.ts index b077bb2..3eaa595 100644 --- a/src/cool/bootstrap/module.ts +++ b/src/cool/bootstrap/module.ts @@ -72,25 +72,23 @@ export function createModule(app: App) { if (d) { Object.assign(e, d); - - // 注册组件 - e.components?.forEach(async (c: any) => { - const v = await (isFunction(c) ? c() : c); - const n = v.default || v; - app.component(n.name, n); - }); - - // 注册指令 - e.directives?.forEach((v) => { - app.directive(v.name, v.value); - }); - - // 安装事件 - if (d.install) { - d.install(app, d.options); - } } + // 安装事件 + e.install?.(app, d.options); + + // 注册组件 + e.components?.forEach(async (c: any) => { + const v = await (isFunction(c) ? c() : c); + const n = v.default || v; + app.component(n.name, n); + }); + + // 注册指令 + e.directives?.forEach((v) => { + app.directive(v.name, v.value); + }); + // 合并 deepMerge(service, mergeService(e.services || [])); diff --git a/src/modules/demo/directives/color.ts b/src/modules/demo/directives/color.ts new file mode 100644 index 0000000..8c5b1c6 --- /dev/null +++ b/src/modules/demo/directives/color.ts @@ -0,0 +1,5 @@ +export default { + created(el: HTMLElement, binding: any) { + el.style.color = binding.value; + } +};