当使用 WinJS 在 Windows Metro 中发生未处理的异常时,我想导航到我的应用程序的主页并使用 FlyOut 显示错误。问题是程序仍然继续到terminateAppHandler
base.js 中。
这是我到目前为止得到的:
WinJS.Application.onerror = function (customEventObject) {
// Get the error message and name for this exception
var errorMessage = customEventObject.detail.error.message;
var errorName = customEventObject.detail.error.name;
// Bind them in an optionsObject to pass with the navigation
var optionsObject = { errName: errorName, errMsg: errorMessage };
// Navigate home with information concerning the error
WinJS.Navigation.navigate("/pages/home/home.html", optionsObject);
// Need something to tell Windows that the error is "taken care" of
return false; // ??
}
我在这里结束,终止应用程序:
var terminateAppHandler = function (data) {
debugger;
MSApp.terminateApp(data);
};
欢迎任何建议或意见!