可能未处理的拒绝:{} [英] Possibly unhandled rejection: {}

查看:28
本文介绍了可能未处理的拒绝:{}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:

可能未经处理的拒绝:{}

Possibly unhandled rejection: {}

我阅读了本主题中的解决方案:Angular 1.6.0:可能未经处理的拒绝"错误

I read the solution in this topic : Angular 1.6.0: "Possibly unhandled rejection" error

我试过了,但我不知道我把固定代码放在哪里,请帮助我,谢谢谢谢大家!

i tried But i dont know where i put fixed code, please kindly help me, thanks Thanks all !

推荐答案

第一个选项是通过在 $qProvider 配置中使用 errorOnUnhandledRejections 禁用错误来隐藏错误:

First option is simply to hide an error by disabling them with errorOnUnhandledRejections in $qProvider configuration:

app.config(['$qProvider', function ($qProvider) {
    $qProvider.errorOnUnhandledRejections(false);
}]);

但是这只会关闭日志记录.错误本身将保持

BUT this will only switch off logging. The error itself will remain

更好的解决方案在这种情况下将是 - 使用 .catch() 方法处理拒绝:

The better solution in this case will be - handling a rejection with .catch() method:

service.doSomething()
 .then(function (response) {
   //normal processing
})
 .catch(function (err) {
     console.log(err);
     throw err;
});

有用的链接:

这篇关于可能未处理的拒绝:{}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆