Gil*_*tes 50 typescript angular
我正在阅读Angular 2 "5 Min Quickstart"并且有这样一条线:
import { Component } from '@angular/core';"
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚,@这个导入中的符号是什么?TypeScript文档也没有说明这一点.
这是什么意思?
ray*_*ray 25
同样重要的是,您也可以使用@非npm包的符号范围.您可以在项目中使用它作为引用不同目录的简短方法.
即
import { MyService } from '@services/my.service';
import { HelloWorldComponent } from '@components/hello-world.component';
Run Code Online (Sandbox Code Playgroud)
代替
import { MyService } from '../../../../my.service';
import { HelloWorldComponent } from '../shared/deeply/nested/hello-world/hello-world.component';
Run Code Online (Sandbox Code Playgroud)
为此,您只需配置tsconfig.json文件(在项目的根目录下),如下所示:
{
"compileOnSave": false,
"compilerOptions": {
// omitted...
"baseUrl": "src",
"paths": {
"@services/*": ["app/path/to/services/*"],
"@components/*": ["app/somewhere/deeply/nested/*"],
"@environments/*": ["environments/*"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
查看Angular Firebase的完整详细信息
这只是Angular使用的命名约定.自发布以来,他们将其重命名为@ angular/core而不是angular2/core.
它引用了框架的核心组件.
(发现在post- angularjs 2中,没有找到角度材料@ angular/core)
| 归档时间: |
|
| 查看次数: |
11504 次 |
| 最近记录: |