使用angularfire2订阅auth对象。运行此代码工作正常,authData对象将打印到控制台:
this.af.auth.subscribe(authData => {
console.log(authData);
});
输出:Object {auth: X, uid: "xXj8n6KnZcNDU8rBH....", provider: 3, google: Gi}
但是当我想只打印其中一个属性时,它会说该对象为null:
this.af.auth.subscribe(authData => {
console.log(authData);
console.log(authData.uid);
});
错误:Cannot read property 'uid' of null
如何访问authData
的属性?