JS文件中的System.register是什么意思? [英] What is mean by System.register in JS file?

查看:1744
本文介绍了JS文件中的System.register是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JS文件中的System.register是什么意思,而在角度2中使用指令。

What is mean by System.register in JS file, while using directives in angular 2.

推荐答案

我认为这个问题不是特定于angular2中的指令,它是关于使用SystemJS的ES6,TypeScript和其他现代编译器的一般性问题。简短的回答 - 它是由System.js创建的包装器,用于隔离代码并注入外部依赖项。

I think this question is not specific to directives in angular2, it is general question about ES6, TypeScript and other modern compilers which use SystemJS. The short answer - it is wrapper created by System.js to isolate code and inject external dependencies.

此代码:

  import { p as q } from './dep';

  var s = 'local';

  export function func() {
    return q;
  }

  export class C {
  }

将生成:

System.register(['./dep'], function($__export, $__moduleContext) {
 var s, C, q;
 function func() {
   return q;
 }
 $__export('func', func);
 return {
   setters: [
   // every time a dependency updates an export, 
   // this function is called to update the local binding
   // the setter array matches up with the dependency array above
   function(m) {
     q = m.p;
   }
   ],
   execute: function() {
     // use the export function to update the exports of this module
     s = 'local';
     $__export('C', C = $traceurRuntime.createClass(...));
     var moduleName = $__moduleContext.id;
   }
 };
});

此处 - 系统注册你可以找到关于这个问题的更多细节信息。

Here - System register you can find more detail inforamtion about thins question.

这篇关于JS文件中的System.register是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆