我在vscode中得到了以下錯誤:
我在vscode中得到了以下錯誤。
屬性'uid'不存在于型別'Promise'.ts(2339)
我在 updateProfile 中也得到了同樣的錯誤:
屬性'updateProfile'在型別'Promise'上不存在。
代碼:
export class SignupPage 實作OnInit {
email: string;
pwd: string;
username: string;
constructor(public fs: AngularFirestore, public af: AngularFireAuth, public nav: NavController) { }
signup(){
this.af.createUserWithEmailAndPassword(this。 email, this.pwd).then(( ) => {
localStorage.setItem('usesrid'/span>, this. af.currentUser.uid)。)
this.af.currentUser.updateProfile({
displayName: this.username。
photoURL: ''。
}).then(() => {
this.nav.navigateRoot('/tabs'/span>)
}).catch(err => {
alert(err.message)
})
}).catch(err => {
alert(err.message)
})
}
}
我是Typescript的新手,所以我不太清楚造成這個錯誤的原因可能是什么。
先謝謝你了。
uj5u.com熱心網友回復:
看來你的currentUser是一個承諾,所以你需要使用await或then來獲得實際的用戶:
this.af。 currentUser.then((user) => {
user.updateProfile({
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/319147.html
標籤:
