Reactjs 使用expo react native管理环境
我想知道如何通过世博会管理环境 我试图遵循这个,但我有一个错误,在检测模式 我替换了“expo”中的导入常量;通过从“expo Constants”导入常量 environment.jsReactjs 使用expo react native管理环境,reactjs,react-native,expo,Reactjs,React Native,Expo,我想知道如何通过世博会管理环境 我试图遵循这个,但我有一个错误,在检测模式 我替换了“expo”中的导入常量;通过从“expo Constants”导入常量 environment.js /***************************** * environment.js * path: '/environment.js' (root of your project) ******************************/ import Constants from '
/*****************************
* environment.js
* path: '/environment.js' (root of your project)
******************************/
import Constants from 'expo-constants';
const ENV = {
dev: {
apiUrl: 'http://localhost.com/api',
},
staging: {
apiUrl: "https://website.com/api",
},
prod: {
apiUrl: "https://website.com/api",
}
};
const getEnvVars = (env = Constants.manifest.releaseChannel) => {
// What is __DEV__ ?
// This variable is set to true when react-native is running in Dev mode.
// __DEV__ is true when run locally, but false when published.
if (__DEV__) {
return ENV.dev;
} else if (env === 'staging') {
return ENV.staging;
} else if (env === 'prod') {
return ENV.prod;
}
};
export default getEnvVars;
当我打开“生产模式”时,我有以下错误:
undefined不是对象(正在评估'j.websiteUrl')
如果我能检查模式,我想我的错误会被修复。其他模式是否正常工作?其他模式是否正常工作?