我正在编写一个 Polymer 应用程序,我正在使用 firebase 作为数据库。我有这个代码来进行 firebase 查询:
let users = document.createElement('firebase-collection');
users.location = document.createElement('iron-meta').byKey('firebaseLocation') + 'users';
console.log(users.data);
这段代码运行了两次:
- 在附加方法中。
- 在用户单击网站上的按钮时调用的方法中。
当代码从附加方法运行时,不会打印任何输出,当用户单击按钮时,会加载正确的数据并将其记录到控制台。
这是为什么?
最佳答案
我现在使用不同的方法:
<firebase-document
id="userToConfirmDocument"
location="[[location]]"
data="{{userToConfirm}}"></firebase-document>
<template is="dom-if" if="{{isConfirmed(userToConfirm)}}">
</template
现在调用“isConfirmed”方法,当数据发生变化时 -> 所以我不必寻找生命周期......希望这对某人有帮助:)
亲切的问候
关于javascript - 带有 firebase 的 Google Polymer : timing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33329801/