JavaScript學習,Imports和Exports

JavaScript學習,export和import

exportimport

Exports

定義

The export statement is used when creating JavaScript modules to export functions, objects, or primitive values from the module so they can be used by other programs with import statement.

Exported modules are in strict mode whether you declare them as such or not. The export statement cannot be used in embeded scripts.

當創建JavaScript模型時,從模塊中去導出函數,對象,或原始值,這個export聲明被使用,以便他們能被其他程序用import聲明來使用。

導出的模塊是在嚴格模式下的,無論你如這樣聲明他們或不。這個export表達式不能被用在嵌套的腳本里。

語法

  1. 被命名的Exports(每個模塊0個或者更多的exports)
  2. 默認的Exports(每個模塊1個)
  3. 混合Hybrid Exports

Imports

Exports and Imports

代碼傳到github上去了,js-exports-import-examples

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章