我想使用 polymerfire 从 Firebase 获取数据,但不知何故它不起作用。
Firebase 数据
lol-project (a name with 5 randomized letters)
+- events
+- (some random event id, which is auto-generated)
+- name: "haha"
+- desc: "hihi"
+- (some random event id, which is auto-generated)
+- name: "huhu"
+- desc: "hehe"
代码(Polymer v1.6,Polymerfire v0.10.2)
<link rel="import" href="../../../bower_components/polymerfire/polymerfire.html">
<link rel="import" href="../../../bower_components/polymerfire/firebase-auth.html">
<link rel="import" href="../../../bower_components/polymerfire/firebase-query.html">
...
<firebase-auth user="{{user}}"></firebase-auth>
<firebase-query id="eventquery" path="/events" data="{{events}}"></firebase-query>
<div class="Page-container" id="section1">
<template is="dom-repeat" items="[[events]]" as="item">
<p>[[item.name]]</p>
</template>
</div>
...
properties: {
events: {
type: Object,
observer: '_eventsChanged'
}
},
_eventsChanged: function(newData, oldData) {
console.log("it changed?!");
console.info(newData);
}
Firebase 规则
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
没有错误,没有数据。给出空console.info(newData);
数组。经过数小时的谷歌搜索,我偶然发现了类似的案例,这显然在这里没有得到解答(是的,这个问题与那个问题非常相似)。
有人知道我错过了什么吗?请帮忙。