import and export

Import module import, export derivation module

// Import all 
Import people from './example' // there is a special case, that is, the entire module allows you to import as a single object 
// The module will continue to exist as the export of all properties of the object 
import * as example from " ./example.js " 
the console.log (example.name) 
the console.log (example.age) 
the console.log (example.getName ()) // introduction portion 
import {name, Age} from './example' // deriving default, and only a default 
export default the App // portion derived 
export class App extend Component {};







to sum up:

1. When using Export default export people, the import people to use import (without braces)

 2. a file, there is one and only one Export default . There can be multiple export. 

3 . When used export name, to use import {name} import (remember to bring braces)

 4. When a file, both a Export default when people, there are a plurality of export name or export age, introducing it with people import, {name, Age}

 5. The file appears when a plurality of n export many modules export, in addition to introducing a an import, use may import * as example

 

Guess you like

Origin www.cnblogs.com/chao202426/p/11481879.html