解决自定义指令无法自动注册的问题

This commit is contained in:
icssoa 2023-03-23 11:07:30 +08:00
parent 223badb2ec
commit 2bea8cd73d
2 changed files with 20 additions and 17 deletions

View File

@ -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 || []));

View File

@ -0,0 +1,5 @@
export default {
created(el: HTMLElement, binding: any) {
el.style.color = binding.value;
}
};