Javascript emquire.js和Chrome打印对话框问题
我有一段代码这段代码作为主干应用程序中更改路由的一部分执行:Javascript emquire.js和Chrome打印对话框问题,javascript,google-chrome,backbone.js,media-queries,enquire.js,Javascript,Google Chrome,Backbone.js,Media Queries,Enquire.js,我有一段代码这段代码作为主干应用程序中更改路由的一部分执行: mediaMatchUnRegister: function () { if (this.mediaMatchState.registered) { enquire.unregister(this.mediaMatchState.tabletAndUpQuery) .unregister(this.mediaMatchState.m
mediaMatchUnRegister: function () {
if (this.mediaMatchState.registered) {
enquire.unregister(this.mediaMatchState.tabletAndUpQuery)
.unregister(this.mediaMatchState.mobileQuery);
this.mediaMatchState.registered = false;
}
}
这一切运行正常,但以下情况除外:
应用程序正在Chrome中运行
我点击了页面上的打印按钮,弹出了Chrome打印预览对话框。
如果我没有打开Chrome打印预览对话框,那么它运行得很好。FF和IE没有这个对话框,没有任何问题
该问题在inquire.js中,特别是在clear方法中:
如果我没有触发打印预览对话框,则this.mql是一个MediaQueryList。如果我触发了它,那么this.mql现在是MediaQueryListent。然后失败,因为该对象似乎没有removeListener方法
还有其他人遇到过这种情况吗?“Chrome打印预览”对话框是在转移视线吗?我也有同样的问题。我找不到合理的解释,所以在给removeListener打电话之前,我只是检查了一下: 这远非理想,但至少可以阻止代码被破坏
clear : function() {
each(this.handlers, function(handler) {
handler.destroy();
});
this.mql.removeListener(this.listener);
this.handlers.length = 0; //clear array
},
if(this.mql.removeListener)