当有身份验证和单独的用户时,我试图让 vuefire/vue/firebase 工作。当我手动传递 UID 时,我可以让它工作......
let booksRef = db.ref('Users/' + 'SOhUKhcWzVRZmqe3AfcWMRwQR4r2' + '/Books');
但是,当我尝试将硬编码的 uid 替换为来自 Firebase 的 uid 时,我得到一个空结果......它在调用时基本上还没有准备好,即使用户已登录......:
beforeCreate: function() {
var context = this;
Firebase.auth().onAuthStateChanged(function(user) {
if (user) {
currentUser = user;
context.currentUserId = user.uid;
context.currentUserEmail = user.email;
context.signedIn = true;
}
else {
context.currentUserId = null;
context.currentUserEmail = null; }
});
在创建数据集的路径之前,如何确保首先获得 UID?
谢谢!