12月16

vue component withInstall

| |
15:26 软件分析与设计  From: 本站原创
阅读(355) | 评论(0) | 引用(0)

import type { App, Plugin } from 'vue';
export const withInstall = <T>(component: T, alias?: string) => {
  const comp = component as any;
  comp.install = (app: App) => {
    app.component(comp.name || comp.displayName, component);
    if (alias) {
      app.config.globalProperties[alias] = component;
    }
  };
  return component as T & Plugin;
};




import { withInstall } from '/@/utils';
import appLogo from './src/AppLogo.vue';
export const AppLogo = withInstall(appLogo);

发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emot
打开HTML
打开UBB
打开表情
隐藏
记住我

昵称 : 

密码(可不填) :  游客无需密码

网址 (可不填) : 

电邮 (可不填) :  [注册]