export 相對於提供一個接口給外界,在其他文件中通過import來引用。在一個模塊中,export default 只允許向外暴露一次。
例如:
// test.js
var person = {
name: 'ttt',
age: 35
}
export default person
export var name = 'ttt'
export var age = 30
test.js使用export default 和 export 向外暴露的成員
import person, {name, age as myAge} from './test.js'
console.log(person);
console.log(name + ',' + myAge);