抱歉,功能链不完全是这样,但是我有这段代码
ActivityService._hubConnection.on('Send', (activity: ActivityDto) => {
this.activity = activity;
if (activity.title === 'LOGIN') {
this.showActivity(`${activity.user.firstName} ${activity.user.surname} logged in.`);
} else if (activity.title === 'COMMENT') {
this.showActivity(`${activity.user.firstName} ${activity.user.surname} commented on: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`, null);
} else if (activity.title === 'ASSIGNED') {
this.showActivity(`${activity.user.firstName} ${activity.user.surname} assigned: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`);
} else if (activity.title === 'SYNC COMPLETE') {
this.showActivity(`Sync complete, View Changes`, `/app/main/dashboard/alerts/all`, 'complete');
} else if (activity.title === 'FILE') {
this.showActivity(`${activity.user.firstName} ${activity.user.surname} filed: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`)
} else if (activity.title === 'XPERT SYNC') {
this.showActivity(`Sync In Progress.`, `/app/main/dashboard/activity`, 'start' );
}
});
showActivity(popText, notifLink = null, sync = null) {
this.popupText = popText;
if (notifLink !== null) {
this.notifLink = notifLink;
}
if (sync !== null) {
if (sync === 'complete') {
this._activityService.finishSync();
} else if (sync === 'start') {
this._activityService.startSync();
}
}
this.showNotif();
}
showNotif() {
const notif = <HTMLElement>document.querySelector('.notification-tab');
notif.style.display = 'flex';
notif.style.bottom = '0';
setTimeout(() => {
notif.style.bottom = '-50px';
setTimeout(() => {
notif.style.display = 'none';
}, 500);
}, 5000);
}
现在我无法弄清楚为什么它不起作用,基本上发生的是说正在接收评论,所以activity.title ==='COMMENT',它应该运行showActivity()
函数,然后应该运行运行showNotif()
函数,将断点放在函数的每个部分上,然后断点命中this.showActivity(),但是什么也没发生?没有其他断点被击中,我无法弄清楚问题出在哪里!对我来说没有任何意义。
任何帮助将不胜感激,我不知道可能出什么问题了...
谢谢
答案 0 :(得分:2)
尝试将您的函数包装起来以尝试.. catch,也许存在uncatch异常。
showActivity(popText, notifLink = null, sync = null) {
try {
this.popupText = popText;
if (notifLink !== null) {
this.notifLink = notifLink;
}
if (sync !== null) {
if (sync === 'complete') {
this._activityService.finishSync();
} else if (sync === 'start') {
this._activityService.startSync();
}
}
this.showNotif();
} catch (e) {
console.error(e);
}
}
也包裹在这里)
if (activity.title === 'COMMENT') {
try {
this.showActivity(`${activity.user.firstName} ${activity.user.surname} commented on: XB-ID-${activity.messageId}`, `/app/main/dashboard/xpert-detail/${activity.messageId}/comment`, null);
} catch (e) {
console.error(e);
}
}