我在 VS2017 上使用 UWP javascript 应用程序。每次出现 javascript 异常时,应用程序都会崩溃。可重现的步骤是
1.打开VS2017
2. 从已安装的模板菜单中选择 Javascript
3.选择空白应用程序(通用窗口)
现在在JS项目里面,写可以异常的代码,例如:
var t;
console.log(t.length) //t is undefined, so t.length will cause an error
我的问题如下所述:最佳答案
可以尝试创建WinJs App,提供应用的生命周期管理WinJS.Application
,提供了 onerror 事件来处理应用程序中 Uncaught Error 。
您可以在此处处理事件,并通过 return true
告诉应用程序您已处理异常。 ,则应用程序不会终止。
var app = WinJS.Application;
app.onerror = function (args) {
console.log(args.detail.error);
return true;
};
关于javascript - UWP javascript 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62930550/