- Architecting Angular Applications with Redux,RxJS,and NgRx
- Christoffer Noring
- 217字
- 2021-08-27 19:56:14
Multiple exports
So far, we have only shown how to export one construct. It is possible to export multiple things from one module by adding an export keyword next to all constructs that you wish to export, like so:
export class Math {
add() {}
subtract() {}
}
export const PI = 3.14
Essentially, for everything you want to make public you need to add an export keyword at the start of it. There is an alternate syntax, where instead of adding an export keyword to every construct, we can instead define within curly brackets what constructs should be exported. It looks like this:
class Math {
add() {}
subtract() {}
}
const PI = 3.14
export {
Math, PI
}
Whether you put export in front of every construct or you place them all in an export {}, then end result is the same, it's just a matter of taste which one to use. To consume constructs from this module, we would type:
import { Math, PI } from './module';
Here, we have the option of specifying what we want to import. In the previous example, we have opted to export both Math and PI, but we could be content with only exporting Math, for example; it is up to us.
- 重新定義Spring Cloud實戰
- 網絡故障現場處理實踐(第4版)
- Learning Karaf Cellar
- 面向云平臺的物聯網多源異構信息融合方法
- React:Cross-Platform Application Development with React Native
- Getting Started with Grunt:The JavaScript Task Runner
- 工業互聯網創新實踐
- 物聯網場景設計與開發(初級)
- 移動物聯網:商業模式+案例分析+應用實戰
- 沖擊:5G如何改變世界
- Python API Development Fundamentals
- Intelligent Mobile Projects with TensorFlow
- Enterprise ApplicationDevelopment with Ext JSand Spring
- RestKit for iOS
- 趣話通信:6G的前世、今生和未來