我有一个包含以下内容的.env文件
GOOGLE_PLACES_API = 12345在我的反应本机中,我将它们作为
const GOOGLE_PLACES_API = process.env[GOOGLE_PLACES_API"]如果我把它放在我的视野里
<Text> {GOOGLE_PLACES_API} <Text />它显示在“12345”屏幕上
现在,当我把它放在googlePlacesAutoComplete中时:
<GooglePlacesAutoComplete
query= {{ key: {GOOGLE_PLACES_API} }}
/>它不起作用。我试过了
<GooglePlacesAutoComplete
query= {{ key: "12345" }}
/>这会管用的。
如何在googleplace键中使用env?
发布于 2022-06-18 11:18:40
这就是你要找的东西:)
https://www.npmjs.com/package/react-native-dotenv
似乎你也增加了不必要的括号
key: {GOOGLE_PLACES_API} should be key: GOOGLE_PLACES_APIhttps://stackoverflow.com/questions/72668569
复制相似问题