📜  反应原生环境变量 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:31.910000             🧑  作者: Mango

代码示例1
# .env files
API_URL=https://myapi.com
GOOGLE_MAPS_API_KEY=abcdefgh

# use env
import Config from 'react-native-config'

Config.API_URL  // 'https://myapi.com'
Config.GOOGLE_MAPS_API_KEY  // 'abcdefgh'

# call env
development: ENVFILE=.env.staging react-native run-android
production: cd android && ENVFILE=.env.production ./gradlew assembleRelease