[英]Angular can't find module local file
在我的應用程序的各個組件中,我稱為SharedService
但ts錯誤找不到模塊Sharedservice時
import { SharedService } from 'src/app/shared/shared.service';
即使Path Intellisense指向正確
但是,當我改變為相對
import { SharedService } from '../app/shared/shared.service';
有什么地方需要寫它指向src / ...
我認為您需要按以下方式配置tsconfig.json,
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"components/*": [ "app/components/*" ],
"services/*": [ "app/services/*" ],
"shared/*": [ "app/shared/*" ]
},
您可以執行以下導入
import { SharedService } from 'shared/shared.service';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.