【问题标题】:Firebase Storage in Web Application: storage.useEmulator is not a functionWeb 应用程序中的 Firebase 存储:storage.useEmulator 不是函数
【发布时间】:2021-11-05 02:29:45
【问题描述】:

在我的本地 Web 应用程序开发环境中,Web 应用程序可以正确访问 Firestore 模拟器,但不能正确访问 Storage 模拟器。而是访问生产存储。

我从http://localhost:5000/__/firebase/8.3.0/firebase-storage.js加载模块

我已经从https://firebase.google.com/docs/emulator-suite/connect_storage#web-v8尝试过这个:

var storage = firebase.storage();
storage.useEmulator("localhost", 9199);

但是 useEmulator 功能不存在。这怎么可能?

【问题讨论】:

    标签: javascript firebase-storage firebase-tools


    【解决方案1】:

    storage.useEmulator 函数是在更高版本的 firebase 中引入的。

    【讨论】:

      【解决方案2】:

      您是否在打开之前配置了连接?

      var firebaseConfig = {
         apiKey: '<your-api-key>',
         authDomain: '<your-auth-domain>',
         databaseURL: '<your-database-url>',
         storageBucket: '<your-storage-bucket-url>'
      };
      firebase.initializeApp(firebaseConfig);
      

      而且,我没有直接的经验,但是你有没有尝试过这种方式?

      firebase.storage.useEmulator('localhost', xxxx)
      

      请注意,这可能是一项正在进行的工作:试试这个 cmd:

      firebase --open-sesame storageemulator
      

      【讨论】:

        猜你喜欢
        • 2020-04-18
        • 2020-10-24
        • 1970-01-01
        • 2021-12-26
        • 2020-04-02
        • 2018-07-18
        • 2021-01-29
        • 1970-01-01
        • 2019-10-19
        相关资源
        最近更新 更多