registerComponent.ts 827 B

123456789101112131415161718192021222324
  1. // import Dialog, { Toast, Alert } from '/@/components/basic/dialog'
  2. import Dialog, { Window, Toast, Alert, DialogContent } from '/@/components/basic/dialog';
  3. import Button from '/@/components/basic/button/index.vue';
  4. import type { App } from 'vue';
  5. function setup(...Components) {
  6. Components.forEach((Component) => {
  7. Component.install = function (app: App) {
  8. Component.use && Component.use(app);
  9. app.component(Component.name, Component);
  10. };
  11. });
  12. return Components;
  13. }
  14. // 注册带install与use hook
  15. const registerComponent = setup(Dialog, Window, Toast, Alert, DialogContent, Button);
  16. // console.log('registerComponent', registerComponent)
  17. export default {
  18. install: (app: App) => {
  19. registerComponent.forEach((component) => {
  20. component.install(app);
  21. });
  22. },
  23. };