1. 程式人生 > >ES中的模組匯出匯入,import xxx from 和 import {xxx} from的區別

ES中的模組匯出匯入,import xxx from 和 import {xxx} from的區別

export 和 export default

  1. export與export default均可用於匯出常量、函式、檔案、模組等
  2. 在一個檔案或模組中,export、import可以有多個,export default僅有一個
  3. 通過export方式匯出,在匯入時要加{ },export default則不需要
  4. export能直接匯出變量表達式,export default不行。