A: import module for ES6 manner and exposed objects by:
- ES6 module import: import module name from 'module identifier'; Import 'represents the path';
- And export the export using default ES6 member exposed outwardly;
- export default outwardly exposed members may be received by any variable;
- In one module, export default outwardly exposed only once
- Export default and export may be used simultaneously exposed members in a module;
- export: using the export member outwardly exposed, only the form of {} is received, called export demand;
- export: export multi-member may be exposed outward, while if the dictation members, when we import does not require the {} may not be defined;
- export: the use of export Export Members must be in strict accordance with the export name when to use {} demand acceptance;
- export: export exported using the member, if you want to change the name of a custom reception, to be used as aliases;
test.js file:
// Use default export the export and ES6 member exposed outwardly;
// var info = {
// name: 'ZS',
@ Age: 20 is
//};
// default export info;
Export default { name: 'ZS' , Age: 20 is } Export var title = 'Little Star' ; Export var context = 'ha ha';
main.js file:
import test,{ title as qwer, context} from './test.js'; console.log(test); console.log(qwer); console.log(context);
effect:
Two: Node Import module exposed objects mode and manner:
- In the node: var name = require ( 'module identifiers') into modules;
- module exports and exports to expose members;