有没有办法在 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/