【问题标题】:firebase cloud firestore get started Failed to load errorfirebase cloud firestore get started Failed to load 错误
【发布时间】:2018-04-07 03:33:27
【问题描述】:

我正在尝试制作 firebase firestore 的入门指南,将所有内容复制到此处:https://firebase.google.com/docs/firestore/quickstart?authuser=0。但不断收到Failed to load in chrome 的错误。有人知道我做错了什么吗?非常感谢。

<!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>firebase</title>
      <script src="https://www.gstatic.com/firebasejs/4.12.0/firebase.js"></script>
      <script src="https://www.gstatic.com/firebasejs/4.12.0/firebase-firestore.js"></script>
    </head>
    <body>
      <script>
        // Initialize Firebase
        var config = {
          apiKey: "AIzaSyB__YWuIm8QjQdFLvZ1qv6P5-yVkYv7I9g",
          authDomain: "fireapp-b79d6.firebaseapp.com",
          databaseURL: "https://fireapp-b79d6.firebaseio.com",
          projectId: "fireapp-b79d6",
          storageBucket: "fireapp-b79d6.appspot.com",
          messagingSenderId: "1050532546787"
        };
        firebase.initializeApp(config);
        var db = firebase.firestore();
        db.collection("users").add({
          first: "Ada",
          last: "Lovelace",
          born: 1815
        })
        .then(function(docRef) {
            console.log("Document written with ID: ", docRef.id);
        })
        .catch(function(error) {
            console.error("Error adding document: ", error);
        });
      </script>
    </body>
    </html>

【问题讨论】:

    标签: javascript firebase web google-cloud-firestore


    【解决方案1】:

    您如何运行您的代码?如果我建议您使用 firebase CLI 运行 firebase serve 命令来为您的项目提供服务。 (命令行界面) firebase.google.com/docs/cli,当您使用 firebase cli 服务时,您的项目将服务于:http://localhost:5000/

    【讨论】:

    • 我在 chrome 中运行它。它似乎不适用于chrome。我在Firefox中测试过,它似乎工作。谢谢你的回复。
    • 它应该适用于所有平台。错误信息是什么?
    猜你喜欢
    • 2022-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 1970-01-01
    • 2019-08-30
    • 2015-01-18
    相关资源
    最近更新 更多