Short Import Typescript路径映射在Angular 8项目中不起作用

问题描述 投票:0回答:1

我的Angular项目结构如下:

enter image description here

我的目标是能够使用]将register.component.ts导入auth-routing.module.ts中。

import { RegisterComponent } from '@pages/auth/authpages/register/register.component';

为此,我将路径添加到了tsconfig.json,如下所示:

  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "typeRoots": ["node_modules/@types"],
    "importHelpers": true,
    "target": "es2015",
    "lib": [
      "es2018",
      "dom"
    ],
    "baseUrl": "src",
    "paths": {

      "@pages/*": ["app/pages*"]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

出于某种原因,它仍然无法正常工作。该组件已正确导出,可以使用标准ts路径作为目标。有人知道出什么问题吗?

我的Angular项目结构如下:我的目标是能够从'@ pages / auth / authpages / ...中使用import {RegisterComponent}将register.component.ts导入auth-routing.module.ts中。

json angular typescript path tsconfig
1个回答
0
投票

尝试更改此

© www.soinside.com 2019 - 2024. All rights reserved.