Firebase 远程配置 : Uncaught TypeError: firebase. remoteConfig 不是函数

标签 firebase firebase-remote-config

我正在尝试使用 Firebase 远程配置。我遵循此设置的 firebase 文档 https://firebase.google.com/docs/remote-config/use-config-web#add-remote-config-to-your-app .但是我收到了这个错误 Uncaught TypeError: firebase.remoteConfig is not a function。

我在这里做什么:

index.html 文件

    	<!-- The core Firebase JS SDK is always required and must be listed first -->
    <script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>

    <!-- TODO: Add SDKs for Firebase products that you want to use
         https://firebase.google.com/docs/web/setup#available-libraries -->
    <script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-analytics.js"></script>

    <script>
      // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "api-key",
      authDomain: "project-id.firebaseapp.com",
      databaseURL: "https://project-id.firebaseio.com",
      projectId: "project-id",
      storageBucket: "project-id.appspot.com",
      messagingSenderId: "sender-id",
      appId: "app-id",
      measurementId: "G-measurement-id",
    };
      // Initialize Firebase
      firebase.initializeApp(firebaseConfig);
      firebase.analytics();
    </script>

<script>
const remoteConfig = firebase.remoteConfig();
remoteConfig.settings = {
  minimumFetchIntervalMillis: 3600000,
};

remoteConfig.defaultConfig = ({
  'test': 'Welcome',
});

console.log(remoteConfig.getasString("test"));
</script


我想我在这一行中得到了这个错误 const remoteConfig = firebase.remoteConfig(); .提前致谢。

最佳答案

在我的 React 应用程序中,问题是缺少下面的导入语句:

import "firebase/remote-config";

关于Firebase 远程配置 : Uncaught TypeError: firebase. remoteConfig 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60722004/

相关文章:

ios - 将 Firebase 数据库子级映射到 swift 3 对象

java - 使用手机登录 Firebase 返回空指针

Firebase函数: Cannot set property config of#<Object> which has only a getter

ios - 不知道在哪里添加pod文件flutter ios安装

node.js - TypeError : admin. firestore.collection不是函数

java - 我可以从 Firebase Remote Config 的默认值中获取 JSONObject

ios - 带有观众的 Firebase 远程配置不起作用

Firebase 远程配置替代方案

firebase - 对于 Firebase AB 测试实验,是否会追溯使用激活事件?

redux - 如何在 flutter redux 中创建商店时从服务器异步加载应用程序状态?