export及export default的區別

export及export default的區別
在JavaScript ES6中,export與export default均可用於導出常量、函數、文件、模塊等,你可以在其它文件或模塊中通過import+(常量 | 函數 | 文件 | 模塊)名的方式,將其導入,以便能夠對其進行使用,但在一個文件或模塊中,export、import可以有多個,export default僅有一個。 

1.export與export default均可用於導出常量、函數、文件、模塊等

2.在一個文件或模塊中,export  、import可以有多個,export default僅有一個

3.通過export方式導出,在導入時要加{ },export default則不需要

4.export能直接導出變量表達式,export default不行

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