import type { Plugin, App } from "vue"; export type SFCWithInstall = T & Plugin; export function withInstall(comp: T) { (comp as SFCWithInstall).install = function (app: App) { const { name } = comp as unknown as { name: string }; app.component(name, comp as SFCWithInstall); //将组件注册成全局的 }; return comp as SFCWithInstall; }