ES6

[ES6] ES6 Syntax

Posted by Jarxi on 2020-11-09

ES6 Syntax

Named Export vs. Default Export

Named Export

1
2
3
4
5
6
// teacher.js
export class Teacher {
constructor(name){
super(name)
}
}
1
2
// index.js
import { Teacher } from './teacher'

Default Export

1
2
3
4
5
6
// teacher.js
export default class Teacher {
constructor(name){
super(name)
}
}
1
2
// index.js
import Teacher from './teacher'

Mixed Export

1
2
// index.js
import { Teacher } from './teacher'

Default Export

1
2
3
4
5
6
7
8
9
10
// teacher.js
export function promote(){

}

export default class Teacher {
constructor(name){
super(name)
}
}
1
2
// index.js
import Teacher, { promote } from './teacher'


支付宝打赏 微信打赏

赞赏一下