我正在尝试制作一个弹出框来确认您是否要删除文档。如果我尝试:
if(alertify.confirm("Delete this?')) {
this.store.findRecord('document', docId, {backgroundReload: false}).then((doc) => {
doc.destroyRecord();
alertify.success('Document successfully deleted!');
}
它不会在运行删除代码之前等待确认,因为据我了解, alertify.confirm 是非阻塞的。如果我尝试:
deleteFile(docId) {
alertify.confirm("Are you sure you want to delete this document?", function (e) {
if (e) {
this.store.findRecord('document', docId, {backgroundReload: false}).then((doc) => {
doc.destroyRecord();
alertify.success('Document successfully deleted!');
});
} else {
alertify.error('Something went wrong!');
}
});
}
它确实要求确认,但删除代码不起作用,因为商店未定义,所以 findRecord 不起作用。我尝试将商店作为服务注入,但这也不起作用。有没有办法让这个确认框工作?