mirror of
				https://github.com/antd-tiny-vue/antd-tiny-vue.git
				synced 2025-11-01 01:01:44 +08:00 
			
		
		
		
	feat: add global register
This commit is contained in:
		
							
								
								
									
										1
									
								
								components/components.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								components/components.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | export { default as Button } from './button' | ||||||
| @@ -1,7 +1,13 @@ | |||||||
| export {} | import type { App } from 'vue' | ||||||
|  | import * as components from './components' | ||||||
|  |  | ||||||
| const aaa = () => { | export default { | ||||||
|   // TODO |   install(app: App) { | ||||||
|  |     for (const componentsKey in components) { | ||||||
|  |       const component = (components as any)[componentsKey] | ||||||
|  |       if (component.install) { | ||||||
|  |         app.use(component) | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| export default aaa |  | ||||||
|   | |||||||
| @@ -2,11 +2,13 @@ import type { Theme } from 'vitepress' | |||||||
| // eslint-disable-next-line import/no-named-as-default | // eslint-disable-next-line import/no-named-as-default | ||||||
| import DefaultTheme from 'vitepress/theme' | import DefaultTheme from 'vitepress/theme' | ||||||
| import { AntdTheme } from 'vite-plugin-vitepress-demo/theme' | import { AntdTheme } from 'vite-plugin-vitepress-demo/theme' | ||||||
|  | import Antd from '../../../components' | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   ...DefaultTheme, |   ...DefaultTheme, | ||||||
|   enhanceApp(ctx) { |   enhanceApp(ctx) { | ||||||
|     DefaultTheme.enhanceApp?.(ctx) |     DefaultTheme.enhanceApp?.(ctx) | ||||||
|     ctx.app.component('Demo', AntdTheme) |     ctx.app.component('Demo', AntdTheme) | ||||||
|  |     ctx.app.use(Antd) | ||||||
|   } |   } | ||||||
| } as Theme | } as Theme | ||||||
|   | |||||||
| @@ -10,7 +10,9 @@ title: 基础按钮 | |||||||
| <script lang="ts" setup></script> | <script lang="ts" setup></script> | ||||||
|  |  | ||||||
| <template> | <template> | ||||||
|   <div></div> |   <div> | ||||||
|  |     <a-button>这是按钮</a-button> | ||||||
|  |   </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <style scoped></style> | <style scoped></style> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user