React Native DEV 和 PROD 变量 [英] React Native DEV and PROD variables
本文介绍了React Native DEV 和 PROD 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何知道我的 React Native 应用程序是在生产环境还是开发环境中运行?JavaScript 中是否有某种方法可以告诉?有没有传入的全局变量?
How do I know if my React Native app is running in production or development? Is there some sort of way within JavaScript to tell? Is there a global that is passed in?
推荐答案
您可以使用 JavaScript 中的 __DEV__
全局变量来确定您是否正在使用 React Native 打包程序.如果您在 iOS 模拟器或 Android 模拟器中运行您的应用,__DEV__
将设置为 true
.
You can use the __DEV__
global variable in JavaScript to determine if you're using React Native packager or not. If you are running your app in the iOS Simulator or Android emulator __DEV__
will be set to true
.
https://facebook.github.io/react-native/docs/javascript-environment.html
这篇关于React Native DEV 和 PROD 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文