【问题标题】:React Native: cannot read / update app.json from app.config.jsReact Native:无法从 app.config.js 读取/更新 app.json
【发布时间】:2021-07-08 04:05:54
【问题描述】:

Expo docs 提到能够从app.config.js 读取/更改app.json 的内容。我正在尝试从 app.config.json 设置 Google Maps API 密钥(当前位于 app.json 中)。但我无法从app.config.js阅读它

app.json

{
 ...
  "android": {
    "config": {
      "googleMaps": {
        "apiKey": "xxx" //set this from app.congif.js in order to use .env variable
      }
    }
  }
}

app.config.js

export default ({ config }) => {
    
    console.log(config.android)
    //set key here
    
    return {
      ...config,
    };
  };

console.log 的结果是undefined

【问题讨论】:

    标签: react-native google-maps expo react-native-maps


    【解决方案1】:

    检查"android" 属性是否在"expo" 之下。我使用的项目曾经在"expo" 之外有"android"。我想 expo 在底层并没有区别,但是在使用 app.config.js 时,您只能访问 "expo" attr 内的数据。

    【讨论】:

      猜你喜欢
      • 2020-02-15
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 2019-03-27
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      相关资源
      最近更新 更多