ionic-framework - 调用 ionic cordova build --release android 时出现 UnhandledPromiseRejectionWarning
问题描述
每当我尝试使用时,我都会收到此错误消息
ionic cordova build --release android
:
(节点:1512) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。此错误源于在没有 catch 块的情况下抛出异步函数内部,或拒绝未使用 .catch() 处理的承诺。(拒绝 ID:1)(节点:1512)[DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。将来,未处理的 Promise 拒绝将使用非零退出代码终止 Node.js 进程。
感谢您的回答!
解决方案
当你调用一个 promise 并且没有向它添加一个 catch 块时,这个警告就会发生。当 promise 调用被拒绝时,会调用 catch 块。
例如:
var foo = function () {
fooPromise
.then(function (res) {
// Do something with the response of the promise
})
.catch(function (err) {
// handle the error
});
};
查看 Javascript 文档以获取更多信息:这里
推荐阅读
- javascript - 为什么这种尝试检索数组的最小数量不起作用?
- image - 通过http传输图像数据的Multipart-data vs base64 String
- fonts - Chart.js v3:如何增加图表图例的字体大小?
- javascript - 带有计时器的 Javascript 或 Jquery 函数,每次调用时都会重置
- database - 备份和恢复 Flutter SQFlite 数据库
- redis - 如何解析redis慢日志
- python - 替代在 wxPython Grid 中有一个表
- python - 根据参数过滤
- import - odoo v14:从 xlsx 或 eml 导入票证及其消息
- javascript - expo 错误“元素类型无效:需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:对象。”