我正在尝试配置路径Angular 6
库(我已经成功配置了以前的 Angular 项目的路径)
这是我以前的应用程序的工作原理tsconfig.json
file:
"compilerOptions": {
[...]
"baseUrl": "src",
"paths": {
"@class/*": [ "app/class/*" ],
"@services/*": [ "app/services/*" ],
"@views/*": [ "app/views/*" ]
}
}
然后使用它,例如:
Import { Item } from '@class/item';
在我的新应用程序中,我正在尝试同样的方式tsconfig.**lib**.json
file:
"compilerOptions": {
[...]
"baseUrl": "src",
"paths": {
"@class/*": [ "lib/class/*" ],
"@services/*": [ "lib/services/*" ],
"@views/*": [ "lib/views/*" ]
}
}
我尝试像这样在我的库的组件中导入一个类,但它不起作用(VSCode 找不到该文件):
Import { Item } from '@class/item';
请注意,import
主项目中的语句正在运行:
Import { Item } from 'myLibrary';
知道我哪里做得不好吗?
感谢您的帮助。