diff --git a/README-zh_CN.md b/README-zh_CN.md index 560f2ff..cce7b43 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -6,7 +6,7 @@ - [Install](#install) - [Quick Start](#quick-start) -- [API](#API) +- [API](#api) - [Examples](#examples) - [FAQ](#faq) - [Related Efforts](#related-efforts) @@ -18,6 +18,32 @@ npm install @opensumi/di --save yarn add @opensumi/di ``` +将您的tsconfig.json修改为包含以下设置: + +```json +{ + "compilerOptions": { + "experimentalDecorators": true, + "emitDecoratorMetadata": true + } +} +``` + +为Reflect API添加一个polyfill(下面的例子使用reflect-metadata)。你可以使用: + +- [reflect-metadata](https://www.npmjs.com/package/reflect-metadata) +- [core-js (core-js/es7/reflect)](https://www.npmjs.com/package/core-js) +- [reflection](https://www.npmjs.com/package/@abraham/reflection) + +Reflect polyfill的导入应该只添加一次,并且在使用DI之前: + +```typescript +// main.ts +import "reflect-metadata"; + +// 你的代码... +``` + ## Quick Start 让我们从一个简单的例子开始: diff --git a/README.md b/README.md index e318ee4..113ea6b 100644 --- a/README.md +++ b/README.md @@ -23,18 +23,44 @@ This tool will help you achieve dependency inversion effectively without concern - [Install](#install) - [Quick Start](#quick-start) -- [API](#API) +- [API](#api) - [Examples](#examples) - [FAQ](#faq) - [Related Efforts](#related-efforts) -## Install +## Installation ```sh npm install @opensumi/di --save yarn add @opensumi/di ``` +Modify your tsconfig.json to include the following settings: + +```json +{ + "compilerOptions": { + "experimentalDecorators": true, + "emitDecoratorMetadata": true + } +} +``` + +Add a polyfill for the Reflect API (examples below use reflect-metadata). You can use: + +- [reflect-metadata](https://www.npmjs.com/package/reflect-metadata) +- [core-js (core-js/es7/reflect)](https://www.npmjs.com/package/core-js) +- [reflection](https://www.npmjs.com/package/@abraham/reflection) + +The Reflect polyfill import should only be added once, and before DI is used: + +```typescript +// main.ts +import "reflect-metadata"; + +// Your code here... +``` + ## Quick Start Let's start with a simple example: