对不起,不完全是函数链,但我有以下代码
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 ===‘注释’,它应该运行showActivity()函数,然后运行showNotif()函数,我在函数的每个部分放置断点,断点到达this.showActivity(),但是什么都没有发生?没有其他的断点被击中,我不知道是什么问题!对我来说没有任何意义。
任何帮助都会很感激,我不知道会出什么问题.
谢谢
发布于 2018-06-26 06:30:36
尝试包装你的函数来尝试..。抓住,也许有未捕获的例外。
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);
}
}https://stackoverflow.com/questions/51035960
复制相似问题