Programing

"@" 기호는 '@angular/core'에서 { Component } 가져오기 문에서 무엇을 의미하십니까?

c10106 2022. 3. 25. 21:13
반응형

"@" 기호는 '@angular/core'에서 { Component } 가져오기 문에서 무엇을 의미하십니까?

나는 각도 2 "5분 빠른 시작"을 읽고 있는데 다음과 같은 대사가 있다.

import { Component } from '@angular/core';"

나는 알 수가 없다, 무슨 일이야?@그 수입품에서 만든 상징?TypeScript 문서들 또한 그것에 대해 아무 말도 하지 않는다.

그것은 무엇을 뜻하나요?

또한 관련성이 있는 것은 다음과 같은 기능을 사용할 수 있다는 것이다.@npm이 아닌 패키지에 대한 기호 범위 지정.당신은 이것을 다른 디렉토리를 참조하는 짧은 방법으로 당신의 프로젝트에서 사용할 수 있다.

import { MyService } from '@services/my.service';
import { HelloWorldComponent } from '@components/hello-world.component';

대신에

import { MyService } from '../../../../my.service';
import { HelloWorldComponent } from '../shared/deeply/nested/hello-world/hello-world.component';

이렇게 하려면 tsconfig.json 파일(프로젝트 루트)을 다음과 같이 구성하면 된다.

{
  "compileOnSave": false,
  "compilerOptions": {

    // omitted...

    "baseUrl": "src",
    "paths": {
      "@services/*": ["app/path/to/services/*"],
      "@components/*": ["app/somewhere/deeply/nested/*"],
      "@environments/*": ["environments/*"]
    }
  }
}

각화기지에서 전체 세부 정보 보기

@scope_name/package_name

이것은 NPM 기능, 범위 이름, @과 슬래시 사이의 모든 것이 당신의 범위 이름이 될 것이다.

npm 범위 문서

이건 각도가 사용하는 이름 지정 규칙일 뿐이야릴리즈 이후 그들은 각도2/코어 대신 @angular/core로 이름을 바꾸었다.

그것은 프레임워크의 핵심 요소들을 언급한다.

(각도 소재가 @angular/core인 포스트 각도js 2에서 발견되지 않음)

참조URL: https://stackoverflow.com/questions/37372816/what-does-symbol-mean-in-import-component-from-angular-core-statem

반응형