使用 polymefire firebase-query 元素没有返回数据
No data returned using polymefire firebase-query element
我正在创建一个 dom 模块来在 div 中显示我的 firebase 数据。我在 https://www.youtube.com/watch?v=9AHDSGitDP0&t=639s but the firebase-query component is not pulling in the data. No data appears in the console other than my signed in user data and there are no errors. I saw that other people had issues pulling in data with polymerfire and I tried the solution here but no luck:
观看了 Polycast 视频
有人可以帮忙吗?
在我的 html 主页面中,我有以下内容:
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="stylesheets/style.css">
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymerfire/polymerfire.html">
<link rel="import" href="../bower_components/polymerfire/firebase-app.html">
<link rel="import" href="../bower_components/polymerfire/firebase-database-script.html">
<link rel="import" href="../bower_components/webcomponentsjs/webcomponents-lite.js">
<link rel="import" href="elements/browse-events.html"> <!-- my custom component -->
</head>
<body>
<firebase-app
api-key=""
auth-domain=""
database-url=""
project-id=""
storage-bucket=""
messaging-sender-id="">
</firebase-app>
<!-- my custom component -->
<browse-events></browse-events>
</body>
这是我的组件文件中的代码 (browse-events.html)
<!-- dependencies -->
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymerfire/polymerfire.html">
<link rel="import" href="../bower_components/polymerfire/firebase-app.html">
<link rel="import" href="../bower_components/polymerfire/firebase-database-script.html">
<link rel="import" href="../bower_components/polymerfire/firebase-database-behavior.html">
<link rel="import" href="../bower_components/polymerfire/firebase-query.html">
<dom-module id="browse-events">
<template>
<firebase-query
id="query-all"
app-name="authtest-54513"
path="/events"
data="{{events}}">
</firebase-query>
<template is="dom-repeat" items="[[events]]" as="event">
<div>
<h1>[[event.title]]</h1>
</div>
</template>
</template>
<script>
Polymer({
is:'browse-events',
properties: {
events: {
type: Object
}
}
});
</script>
</dom-module>
如果您在 firebase-query 中使用 app-name,则需要在 firebase-app
中指定 name
。如果您在应用中只使用一个 firebase-app
,则可以在 firebase-app
中省略 name
,在其他 polymerfire 元素中省略 app-name
。
属性 events
可能是数组而不是对象:
If the child nodes of the query are objects (most cases), data
will
be an array of those objects with an extra $key
field added to
represent the key. If the child nodes are non-object leaf values,
data
will be an array of objects of the structure {$key: key, $val:
val}
.
https://github.com/firebase/polymerfire/blob/master/firebase-query.html
附带说明:您只需要在 browse-events
元素中导入 firebase-query
。 Firebase-query 会将它需要的脚本导入 运行 本身。 (与主 html 页面中的 firebase-app 相同)
我正在创建一个 dom 模块来在 div 中显示我的 firebase 数据。我在 https://www.youtube.com/watch?v=9AHDSGitDP0&t=639s but the firebase-query component is not pulling in the data. No data appears in the console other than my signed in user data and there are no errors. I saw that other people had issues pulling in data with polymerfire and I tried the solution here but no luck:
有人可以帮忙吗?
在我的 html 主页面中,我有以下内容:
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="stylesheets/style.css">
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymerfire/polymerfire.html">
<link rel="import" href="../bower_components/polymerfire/firebase-app.html">
<link rel="import" href="../bower_components/polymerfire/firebase-database-script.html">
<link rel="import" href="../bower_components/webcomponentsjs/webcomponents-lite.js">
<link rel="import" href="elements/browse-events.html"> <!-- my custom component -->
</head>
<body>
<firebase-app
api-key=""
auth-domain=""
database-url=""
project-id=""
storage-bucket=""
messaging-sender-id="">
</firebase-app>
<!-- my custom component -->
<browse-events></browse-events>
</body>
这是我的组件文件中的代码 (browse-events.html)
<!-- dependencies -->
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymerfire/polymerfire.html">
<link rel="import" href="../bower_components/polymerfire/firebase-app.html">
<link rel="import" href="../bower_components/polymerfire/firebase-database-script.html">
<link rel="import" href="../bower_components/polymerfire/firebase-database-behavior.html">
<link rel="import" href="../bower_components/polymerfire/firebase-query.html">
<dom-module id="browse-events">
<template>
<firebase-query
id="query-all"
app-name="authtest-54513"
path="/events"
data="{{events}}">
</firebase-query>
<template is="dom-repeat" items="[[events]]" as="event">
<div>
<h1>[[event.title]]</h1>
</div>
</template>
</template>
<script>
Polymer({
is:'browse-events',
properties: {
events: {
type: Object
}
}
});
</script>
</dom-module>
如果您在 firebase-query 中使用 app-name,则需要在 firebase-app
中指定 name
。如果您在应用中只使用一个 firebase-app
,则可以在 firebase-app
中省略 name
,在其他 polymerfire 元素中省略 app-name
。
属性 events
可能是数组而不是对象:
If the child nodes of the query are objects (most cases),
data
will be an array of those objects with an extra$key
field added to represent the key. If the child nodes are non-object leaf values,data
will be an array of objects of the structure{$key: key, $val: val}
. https://github.com/firebase/polymerfire/blob/master/firebase-query.html
附带说明:您只需要在 browse-events
元素中导入 firebase-query
。 Firebase-query 会将它需要的脚本导入 运行 本身。 (与主 html 页面中的 firebase-app 相同)