Skip to content

agileago/vue3-oop

Repository files navigation

vue3 oop

类组件+自动化的依赖注入(可选) = 极致的代码体验

前提条件

需要reflect-metadata 的支持

yarn add @abraham/reflection injection-js 

项目入口需要引入 reflect-metadata

import '@abraham/reflection'

tsconfig.json 需要增加配置:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "useDefineForClassFields": false
  } 
}

安装

yarn add vue3-oop 

vite配置

因为esbuild不支持装饰器的metadata属性,所以需要安装 vite-plugin-ts 插件使用原始ts编译

依赖注入

Angular文档