Angular2 的 @符号究竟是啥意思?

2017-03-22 16:35:06 +08:00
 NullMan
import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `<h1>Hello {{name}}</h1>`
})
export class AppComponent { name = 'Angular'; }

这里的“@Component ”的“@”是啥意思?相关知识来由能在哪里看到呢?还有就是“@angular/core ”的“@”又是个啥意思呢?为什么不是"angular/core"? 斜线“/”又是怎么做到的?

还望大家赐教赐教。给出相关知识链接即可。

3527 次点击
所在节点    Angular
4 条回复
suinia
2017-03-22 16:40:58 +08:00
xialdj
2017-03-22 16:44:13 +08:00
这个是 decorator 语法 本来纳入 es6 标准的 后来延到 es7 结果到现在还没加入标准 可能 es2018 或者 2019 ?
xialdj
2017-03-22 16:45:02 +08:00
@angular/core 这个只是单纯的名字而已
aristotll
2017-03-22 17:17:21 +08:00
es6 的语法 类似 Python 的装饰器?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/349497

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX