我得到了错误:
Possibly unhandled rejection: {}
我阅读了本主题中的解决方案:Angular 1.6.0: "Possibly unhandled rejection" error
我试过了但是我不知道我把固定代码放在哪里,请帮助我,谢谢 谢谢大家!
最佳答案
第一个选项是通过在 $qProvider 配置中使用 errorOnUnhandledRejections
禁用它们来隐藏错误:
app.config(['$qProvider', function ($qProvider) {
$qProvider.errorOnUnhandledRejections(false);
}]);
但是 这只会关闭日志记录。错误本身将保留
更好的解决方案在这种情况下将是 - 使用 .catch()
方法处理拒绝:
service.doSomething()
.then(function (response) {
//normal processing
})
.catch(function (err) {
console.log(err);
throw err;
});
有用的链接:
关于angularjs - 可能未处理的拒绝 : {},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51831457/