我正在开发Windows 8.1的HTML/JS应用程序,并且无法调试附加到顶部NavBar对象的处理程序中正在发生的崩溃当用户从处理程序所附的页面导航时。WinJS NavBar事件处理程序在导航到另一页时崩溃Windows 8.1 HTML5/JS应用程序
功能非常简单:当用户登录到问题的屏幕上时,我使用它的.show()方法自动显示WinJS Flyout。现在,当用户调用顶层NavBar对象时,我有一个隐藏Flyout对象的处理程序。我还有另一个处理程序,当NavBar被解散时,显示Flyout。
当用户导航到其他页面时会出现此问题。这里是我的问题的屏幕代码:
var appBar = class.that.constructs.NavBar;
ready : function (element, options) {
var self = this;
...
appBar.topControl.onbeforeshow = self.hideFlyout;
appBar.topControl.onbeforehide = self.showFlyout;
$('#flyout').addClass('activated');
$('#flyout')[0].winControl._sticky = true;
$('#flyout')[0].winControl.show();
},
hideFlyout: function() {
$('#flyout').topControl.winControl.hide();
},
showFlyout: function() {
$('#flyout').topControl.winControl.show();
},
unload: function() {
appBar.topControl.onbeforeshow = null;
appBar.topControl.onaftershow = null;
}
正如你所看到的,我删除卸载后的页面的事件处理程序,但这似乎并没有这样的伎俩。我仍然得到这个崩溃错误:
JavaScript runtime error: Unable to get property 'classList' of undefined or null reference
它在showFlyout
处理程序崩溃。有没有人对如何在导航到新页面时避免崩溃提出任何建议?
你有没有试着调试代码? (进入它?)在崩溃时,看起来像什么样的callstack? – WiredPrairie
@WiredPrairie我确实尝试过。正如我在我的原始文章中所述。该程序在'showFlyout'处理程序的行中崩溃。 callstack指出,在它在该代码行崩溃之前,它显示[External Code]。不确定那是什么意思。 – ariestav
你没有说明你特别试过的东西。 “调试”是一个非常普遍的术语。你可以加入“演出”功能吗? – WiredPrairie