[2020-01-22] module

Module in its own scope in execution, rather than global in scope; this means defined in a module of variables, functions, classes, and so outside the module is not visible, unless you explicitly use

One export form export them. Conversely, if you want to use variables other modules exported, functions, classes, interfaces, etc., when you have to import them, you can use one of the import form

Module is a self-declared; the relationship between the two modules is through the use of imports and exports at the file level established

Module loader module to import other modules. At run time, the role of the module loader in the implementation of this module and executes the code to go to find all the dependencies of this module

1, any file that contains the top-level import or export have been treated as a module. Conversely, if a file without a top import or export declaration, then its content is considered globally visible

 

 

 

 

 

 2, rename exported module

 

 3, export all modules

 

 4, Import

 

 5, default export

 

 

 

 6, and using export = import = require ()

 

 If you are exporting only a single class, or function, using export default

7, to extend the use of re-export

 

 

 

 

 

 8. Do not use the module in the namespace

Guess you like

Origin www.cnblogs.com/QQ-lala/p/12228520.html