在我的项目中尝试实现 alertifyjs 时,我在尝试执行/实现确认方法时遇到了一个奇怪的错误消息:这是我的服务实现:
import { Injectable } from '@angular/core';
declare let alertify: any;
alertify.defaults = {
// notifier defaults
notifier: {
position: 'top-right'
},
};
@Injectable()
export class AlertifyService {
constructor() { }
confirm(message: string, okCallback: () => any) {
alertify.confirm(message, function(e) {
if (e) {
okCallback();
}
});
}
success(message: string) {
alertify.success(message, 3);
}
}
当我调用成功、错误或警告方法时,它可以正常工作,但是当我尝试调用确认方法时,它会破坏应用程序:
hello() {
this.alertify.confirm('Anyone there ?', () => {console.log('hey there ...'); });
}
使用 alertifyjs 版本 1.11.1 ...谢谢。