반응형

자바스크립트를 모듈화 하여 사용할 수 있다.

사용 방법은 아래와 같다.

// default export
export default person

import person from './person.js'
import prs from './person.js' // default export 하였기 때문에 이름을 아무거나 써도 된다


// named export
export const clean = () => {...}
export const baseData = 10;
export smth

import {clean} from './utility.js' // default export를 안했기 때문에 중괄호를 이용해 이름을 지명
import {baseData} from './utility.js'
import {smth} from './utility.js'
import {smth as funcSmith} from './utility.js' // 이름을 지명할 때 사용할 이름 선택 가능
import * as bundled from './utility.js' // bundled.clean 의 방식으로 활용 가능

 

 

반응형

+ Recent posts