firebase.storage()不是JavaScript中的函数 [英] firebase.storage() is not a function in JavaScript

查看:32
本文介绍了firebase.storage()不是JavaScript中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web开发和Firebase的新手,出现了一个错误.我无法解决它,所以来这里寻求帮助.

I'm new to web development and firebase and a error is appearing to me. I've not been able to solve it so came here to seek for help.

显示的错误为firebase.storage() is not a function.看来我的电脑中的储存空间设置不正确.但是,我遵循了从google网站本身下载的说明,它并没有改变任何事情.

The error displayed is firebase.storage() is not a function. It seems that the firestorage is not set correctly in my computer. However, I've followed the instructions download from the google website itself and it did not change a thing.

我在Stack Overflow上看到了一些与此有关的其他问题,但是它们使用node或react并不是我的情况.有人可以给我提示吗?

I've seen some other questions regarding this on Stack Overflow, but they use node or react which is not my case. Can someone give me a hint?

我知道这里没有详细解释,因为正如我之前所说,我不是专家.请宽容,我会更好地提出我的问题.

I know it is not explained in details because, as I said before, I'm not an expert. Please be compreensive and I'll develop better my question.

我创建的代码如下.第一个块是 .html 文件的子集.另一个是我的 .js文件

The code I've created is bellow. The first block is a subset of an .html file. The other one is the body of my .js file

  <!-- Firebase App is always required and must be first -->
      <script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-app.js"></script>
      <!-- Add additional services that you want to use -->
      <script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-auth.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-database.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-firestore.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-messaging.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-functions.js"></script>

      <!-- Inicializa o firebase -->
      <script>
          var config = {
              apiKey: "..",
              authDomain: "..",
              databaseURL: "..",
              projectId: "..",
              storageBucket: "..",
              messagingSenderId: "..",
              appId: ".."
          };
          firebase.initializeApp(config);
      </script>
      <!-- Nosso app -->
      <script src="./app.js"></script>


var fileInput = document.getElementById('file-input');
var stringInput = document.getElementById('string-input');

var ref = firebase.storage();

fileInput.onchange = function (event) {
}

stringInput.onchange = function (event) {

}

推荐答案

您需要包括firebase存储api.

You need to include the firebase storage api.

您可以通过在导入firebase-app脚本后添加以下行来做到这一点:

You can do this by adding this line after you import the firebase-app script:

<script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-storage.js"></script>

您可以在以下代码沙箱中看到一个演示: https://codesandbox.io/s/vqy01k5175

You can see a demo in this code sandbox: https://codesandbox.io/s/vqy01k5175

这篇关于firebase.storage()不是JavaScript中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆