2013-10-29 96 views
1

由于镖里程碑8,那是不可能的他(她)通过以下方法导航离开页面之前,以提醒用户:警报之前卸载在DART M8

window.onBeforeUnload.listen((BeforeUnloadEvent event) { 
    event.returnValue = 'Are you sure you want to leave?'; 
}); 

自Event.returnValue字段已被删除。 你如何用新的API实现这种效果?

这是它是如何使用jQuery做:

$(window).on('beforeunload', function(){ 
    return 'Are you sure you want to leave?'; 
}); 

回答

2

它看起来就像当我们整合了新的眨眼版本 - 闪烁最终加入的BeforeUnloadEvent本地的API得到了下降。在此之前,我们不得不伪造它。

见错误https://code.google.com/p/dart/issues/detail?id=14641

解决方法:像以前一样使用它。传入的事件是BeforeUnloadEvent的子类,并且仍有returnValue。