Polymerfire< firebase-app>元素崩溃的应用程序 [英] Polymerfire <firebase-app> element crashes app

查看:130
本文介绍了Polymerfire< firebase-app>元素崩溃的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚添加了新的Polymerfire < firebase-app> 元素添加到我的(Polymer 1.x + Firebase 3.x)项目中,并使项目崩溃。我希望在本地主机上看到主屏幕加载,但是,我只是得到一个空白屏幕和控制台错误。

my-element.html

I just added the new Polymerfire <firebase-app> element to my (Polymer 1.x + Firebase 3.x) project and it crashed the project. I expected to see the home screen load on localhost but, instead, I just get a blank screen and console error.

<firebase-app auth-domain="my-app-id.firebaseapp.com"
              database-url="https://my-app-id.firebaseio.com/"
              api-key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
</firebase-app>

控制台日志报告以下错误:

控制台.log
$ b

The console log reports the following error:


firebase-app.html:94

未捕获的ReferenceError:未定义firebase

firebase-app.html:94
Uncaught ReferenceError: firebase is not defined

相关代码行(行#94)如下:

firebase-app.html,94行

The relevant line of code (line #94) is the following:

firebase.initializeApp.apply(firebase, init); // Line 94, highlighted error

firebase-app元素的完整源代码位于这里

<!--
@license
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://github.com/firebase/polymerfire/blob/master/LICENSE
-->

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="firebase.html">
<dom-module id="firebase-app">
  <script>
    (function() {
      'use strict';
      /**
       * The firebase-app element is used for initializing and configuring your
       * connection to firebase.
       */
      Polymer({
        is: 'firebase-app',
        properties: {
          /**
           * The name of your app. Optional.
           *
           * You can use this with the `appName` property of other Polymerfire elements
           * in order to use multiple firebase configurations on a page at once.
           * In that case the name is used as a key to lookup the configuration.
           */
          name: {
            type: String,
            value: ''
          },
          /**
           * Your API key.
           *
           * Get this from the Auth > Web Setup panel of the new
           * Firebase Console at https://console.firebase.google.com
           *
           * It looks like this: 'AIzaSyDTP-eiQezleFsV2WddFBAhF_WEzx_8v_g'
           */
          apiKey: {
            type: String
          },
          /**
           * The domain name to authenticate with.
           *
           * The same as your Firebase Hosting subdomain or custom domain.
           * Available on the Firebase Console.
           *
           * For example: 'polymerfire-test.firebaseapp.com'
           */
          authDomain: {
            type: String
          },
          /**
           * The URL of your Firebase Realtime Database. You can find this
           * URL in the Database panel of the Firebase Console.
           * Available on the Firebase Console.
           *
           * For example: 'https://polymerfire-test.firebaseio.com/'
           */
          databaseUrl: {
            type: String
          },
          /**
           * The Firebase app object constructed from the other fields of
           * this element.
           */
          app: {
            type: Object,
            notify: true,
            computed: '__computeApp(name, apiKey, authDomain, databaseUrl)'
          }
        },
        __computeApp: function(name, apiKey, authDomain, databaseUrl) {
          if (apiKey && authDomain && databaseUrl) {
            var init = [{
              apiKey: apiKey,
              authDomain: authDomain,
              databaseURL: databaseUrl
            }];
            if (name) {
              init.push(name);
            }
            firebase.initializeApp.apply(firebase, init);
          } else {
            return null;
          }
          return firebase.app(name);
        }
      });
    })();
  </script>
</dom-module>


推荐答案

来自评论的摘要:@ Bogdan.Nourescu是正确的。我没有正确安装firebase-sdk目录。

Summary from comments: @Bogdan.Nourescu was correct. I did not have the firebase-sdk directory correctly installed.

我必须使用以下命令安装使用Bower的Polymerfire依赖项:

I had to install the Polymerfire dependencies using Bower using the following command:

bower install --save firebase/polymerfire



<注意: bower install --save polymerfire 指向DivShot现在已经过时的版本。

Note: bower install --save polymerfire points to DivShot's version which is now outdated.

这篇关于Polymerfire&lt; firebase-app&gt;元素崩溃的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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