Polymer3和firebase数据库“ Firebase:未创建Firebase应用程序'[DEFAULT]'-调用Firebase App.initializeApp()(app / no-app)”。

时间:2018-10-01 22:12:33

标签: firebase firebase-realtime-database polymer-3.x

从该聚合物3入门工具包写入Firebase数据库时出现问题。我收到这个错误

"Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)." 

该表格似乎正确调用了Firebase,但是访问被拒绝,有人可以向我指出正确的方向吗?

谢谢。

class MyView1 extends PolymerElement {
  static get template() {
    return html`
      <style include="shared-styles">
        :host {
          display: block;

          padding: 10px;
        }
      </style>
      <div class="card">
        <div class="circle">1</div>
        <h1>Agregar una Escuela</h1>
        <iron-form id="form1">
      <form action="/" method="get">
          <paper-input id="school_name" type="text" label="Nombre Escuela"></paper-input>
          <paper-input id="school_address" type="text" label="Dirección"></paper-input>
          <paper-input id="school_type" type="text" label="Tipo de Escuela"> </paper-input>
            <br><br>
            <br>
          <paper-button raised on-click="add">Submit</paper-button>
          <paper-button raised on-click="clear">Reset</paper-button>
      </form>
      </div>

      <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
      <script src="node_modules/web-animations-js/web-animations-next-lite.min.js"></script>

          <script src="https://www.gstatic.com/firebasejs/5.5.2/firebase.js"></script>
          <script src="https://www.gstatic.com/firebasejs/5.5.2/firebase-database.js"></script>
          <script>
         // Initialize Firebase
            var config = {
              apiKey: "AIzaSyC0Mt_4iqqTREXNK5yf6LSdjjJQ_N-Loac",
              authDomain: "cfid-300bc.firebaseapp.com",
              databaseURL: "https://cfid-300bc.firebaseio.com",
              projectId: "cfid-300bc",
              storageBucket: "cfid-300bc.appspot.com",
              messagingSenderId: "1069062310022"
            };
          </script>

    `;
  }
              add() {
                      var database = firebase.database();
                        function writeUserData(school_name, school_address, school_type) {
                        firebase.database().ref('schools/').set({
                          school_name: school_name,
                          school_address: school_address,
                          school_type : school_type
                        });
                        }
                        this.$.school_name.value = null;
                        this.$.school_address.value = null;
                        this.$.school_type.value = null;
                       }
                clear() {
                    this.$.school_name.value = null;
                    this.$.school_address.value = null;
                    this.$.school_type.value = null;
                  }
 }

window.customElements.define('my-view1', MyView1);"

0 个答案:

没有答案