加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular2 – module.id在组件中的含义是什么?

发布时间:2020-12-17 09:11:16 所属栏目:安全 来源:网络整理
导读:在angular2很多次我看到@Component有属性moduleId。这是什么意思? 和在module.id模块是没有定义任何地方仍然应用程序的工作。怎么运行的 ? @Component({ moduleId: module.id,selector: 'ng-app',templateUrl: 'app.component.html',styleUrls: ['app.comp
在angular2很多次我看到@Component有属性moduleId。这是什么意思?
和在module.id模块是没有定义任何地方仍然应用程序的工作。怎么运行的 ?
@Component({
      moduleId: module.id,selector: 'ng-app',templateUrl: 'app.component.html',styleUrls: ['app.component.css'],directives: [AppComponent]
    });
Angular2的beta版本(自alpha.51起)支持组件的相对资产,如@Component装饰器中的templateUrl和styleUrls。

module.id在使用CommonJS时工作。你不需要担心它是如何工作的。

Remember: setting moduleId: module.id in the @Component decorator is
the key here. If you don’t have that then Angular 2 will be looking
for your files at the root level.

来源Justin Schwartzenberger’s post,感谢@Pradeep Jain

2016年9月16日最新更新:

If you are using webpack for bundling then you don’t need
module.id in decorator. Webpack plugins auto handle (add it)
module.id in final bundle

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读