angular - 为什么我得到一个函数而不是 Ionic 4 上 currentUser 的 UID 值?
问题描述
当我在一个应该返回当前用户的 uid 的方法上执行 console.log 时,它会返回该函数。为什么?
我尝试获取 UID 的不同方法:
这是当前用户的价值:
function () { return this.afAuth.auth.currentUser.uid; }
这是当前用户的值:
function () { return this.user.uid }
什么是正确的?为什么无法获得价值?当我创建用户 uid 时,方法是下一个:
const res = await this.afAuth.auth
.createUserWithEmailAndPassword(username, password)
this.afstore.doc(`/users/${res.user.uid}`).set({
username
})
解决方案
最终解决:
最后返回值的唯一方法是:
getUID() {
return this.afAuth.auth.currentUser.uid
}
我按照错误的教程...
推荐阅读
- angular - EventEmitter 没有在 Angular 9 中发射对象
- python-3.x - 如何在不改变python中输入元素顺序的情况下用数字分隔单词
- windows - 在 Eclipse 中调用“make”和在终端中调用“make”有什么区别?
- html - 如何以这种格式 apache 日志?
- visual-studio-code - 在 VS Code 中使用语句自动导入
- laravel - Store multiple rows in multiple tables in Laravel
- git - Understanding Git: Latest push is not visible on production server
- android - How to navigate back in nested graph from the third level to the second level?
- powershell - Error while activating virtual environment in Windows 10 PowerShell
- angular - 使用文件配置生产 Angular 应用程序