Angular 2 - 像#if 这样的预处理器指令

标签 angular typescript

有没有办法在 typescript 上定义预处理器指令,比如 c# 的 #define #if 等,特别是在 angular 2 中?

我正在开发一个多平台项目,我想对移动设备和网络使用相同的代码。问题是当我使用一种平台不支持的技术时。

最佳答案

There is a way to define preprocessor directives on typescript, something like #define #if etc of c#, specially in angular 2

没有。然而,angular 团队使用 webpack,它可以选择定义环境变量并对这些变量进行死代码消除。

更多

https://basarat.gitbooks.io/typescript/content/docs/tips/build-toggles.html

关于Angular 2 - 像#if 这样的预处理器指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39842359/

相关文章:

angular - 是否有用于音频管理的 Angular 4 npm 包?

reactjs - 调度问题 "Argument of type '(调度 : Dispatch<T>) => Promise<void >' is not assignable to parameter of type ' T'.”

angular - 在 mat-grid-list 中设置可调行高

Angular APP_INITIALIZER 是否在延迟加载的模块中工作

angular - 试图理解此代码 : map((data: SearchResponse) => data && data. 项目 || [])

javascript - 功能模块的声明文件 (TypeScript)

cordova - 如何添加Ionic2原生按钮点击音效?

Angular 5 : Pass ng-template down to child component using ngTemplateOutlet

angular - 在 golang 中对 AES 解密的 panic 返回

angular - 如何在 Angular 4 中测试特定的 spec.ts 文件?