if {
db.collection('doctors').get({
success:res=>{
let doctors=res.data
for (let i = 0; i < doctors.length; i++) {
const element = doctors[i].AccountNumber;
if (this.data.AccountNumberInput===doctors[i].AccountNumber) {
wx.hideToast({
success: res => {
wx.showToast({
title: '账号已存在,请重新输入',
icon:"none",
duration:2000
})
},
})
this.setData({
AccountNumberInput:""
})
}else{
wx.showLoading({
title: '提交中,请等待',
icon:"loading",
duration:1000
})
this.pushDb()
}
}
}
})
}
你这里不对吧,this.data.AccountNumberInput这里应该也是一个数组啊 你现在doctors[i].AccountNumber只要有一个和,this.data.AccountNumberInpu相同就执行if,不同就执行else