- Architecting Angular Applications with Redux,RxJS,and NgRx
- Christoffer Noring
- 153字
- 2021-08-27 19:56:15
The default import/export
So far, we have been very explicit with what we import and what we export. We can, however, create a so-called default export, which looks somewhat different to consume:
export default class Player {
attack() {}
move() {}
}
export const PI = 3.13;
To consume this, we can write the following:
import Player from './module';
import { PI } from './module'
Note especially the first row where we no longer use the curly brackets, {}, to import a specific construct. We just use a name that we make up. In the second row, we have to name it correctly as PI, but in the first row we can choose the name. The player points to what we exported as default, that is, the Player class. As you can see, we can still use the normal curly brackets, {}, to import specific constructs if we want to.
推薦閱讀
- 網絡教育學習指導
- RCNP實驗指南:構建高級的路由互聯網絡(BARI)
- 6G潛在關鍵技術(下冊)
- GPS/GNSS原理與應用(第3版)
- Spring Boot 2.0 Projects
- INSTANT PhpStorm Starter
- 計算機網絡與數據通信
- 局域網組建、管理與維護項目教程(Windows Server 2003)
- HTML5 Game development with ImpactJS
- Learning Swift(Second Edition)
- 現代通信系統(第5版)
- Selenium WebDriver 3 Practical Guide
- 基于IPv6的家居物聯網開發與應用技術
- 智能物聯網:區塊鏈與霧計算融合應用詳解
- ElasticSearch Server