【发布时间】:2020-12-18 16:04:28
【问题描述】:
我正在尝试从我的 firebase 实时数据库中添加一个数字,并从 ionic 中添加另一个数字。
ngOnInit() {
this.number = [50]
}
check(){
firebase.database().ref('users/').once('value', (snapshot) => {
snapshot.forEach(snap => {
this.newlist.push(snap.val().referralCode);
if(this.checking.referralCode == snap.val().referralCode){
console.log('Referral Code Exists')
this.presentAlert();
this.auth.onAuthStateChanged(se => {
this.fire = firebase.database().ref('users/' + se.uid).on('value', resp => {
this.afDB.object('users/'+ se.uid).update({
point: parseInt(this.data.point + this.number),
})
console.log(resp)
})
})
return true;
}
else{
console.log('Invalid')
}
})
})
但是结果显示 '050505050505050' 我曾尝试使用 ParseInt() 但这不起作用。
【问题讨论】: