有一个弹出窗口是基于用户将一个操作标记为完成而触发的。但是如果用户勾选了许多项并且没有刷新页面,那么所有之前的弹出窗口都会继续弹出,并且每次都必须从其中的每一个弹出窗口中删除。
不知道这是为什么,我有一个退订。
async checkProgress(){
debugger
if (this.Origin == 'SGBA') {
if (this.data?.action==="update" && this.status == 'Complete') {
//Gets modified document data to pass into progress popout component
let newData;
let q = await this.busiAssessmentService.readOverallData2(this.UID);
const unsubscribe = await onSnapshot(q, (snapshot) => {
let changes = snapshot.docChanges()
console.log(changes.length)
changes.forEach((change) => {
console.log(change.type)
console.log("change.type")
if (change.type === "modified") {
newData = change.doc.data();
console.log("Modified doc: ", change.doc.data());
this.openBox(newData, this.inputSource, this.Category)
return newData;
}
});
},(error) => {
console.log(error)
});
if (newData !== undefined){
unsubscribe();
}
}
}
}
1条答案
按热度按时间yc0p9oo01#
您在错误的位置取消订阅快照,而不是在
this.openBox(newData, this.inputSource, this.Category);
行之后的末尾取消订阅。更新代码: