为什么我得到一个函数而不是 Ionic 4 上当前用户的 UID 值?

Why i'm getting a function instead a value of my UID of the currentUser on Ionic 4?

当我在一个方法上执行 console.log 时,应该 return 当前用户的 uid,它 return 函数。为什么?

我尝试获取 UID 的不同方法:

  1. 这是当前用户的值:

    function () {
        return this.afAuth.auth.currentUser.uid;
    }
    
  2. 这是当前用户的值:

    function () {
        return this.user.uid
     }
    

正确的是什么?为什么取不到值?当我创建用户 uid 时,方法是下一个:

  const res = await this.afAuth.auth
                .createUserWithEmailAndPassword(username, password)

  this.afstore.doc(`/users/${res.user.uid}`).set({
    username
  })

最终解决:

最后 returns 我认为值的唯一方法是:

getUID() {
    return this.afAuth.auth.currentUser.uid
}

我听错教程了...