Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 中 安装system #122

Open
deepthan opened this issue Feb 22, 2021 · 0 comments
Open

Angular 中 安装system #122

deepthan opened this issue Feb 22, 2021 · 0 comments

Comments

@deepthan
Copy link
Owner

1. 下载systemjs

yarn add "@types/systemjs": "^0.20.6",

或者

npm install @types/systemjs --save-dev

2. 配置tsconfig

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": ["system"],  //<-- here
}

3. index.html中引入该js

index.html

  <script src="node_modules/systemjs/dist/system.src.js"></script>

4. type.d.ts中定义System的类型

type.d.ts

declare var System: any;

pages.routing.ts

5. 导入模块

export function loadAuthModule() {
  return System.import('@ithinkdt/pages').then(mod => mod.IThinkDTAuthModule);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant