当我尝试从 Q 打印 promise 对象时,我得到了以下结果。
var Q = require('q');
var defaultPromise = new Q();
console.log('defaultPromise', defaultPromise);
defaultPromise { state: 'fulfilled', value: undefined }
字段状态和值从哪里来,我尝试通过 Visual Studio 代码找到它们,但字段不存在。
最佳答案
A promise must be in one of three states: pending, fulfilled, or rejected.
A promise must provide a then method to access its current or eventual value or reason.
Q(value)
返回一个用值实现的 promise 。在你的情况下,未定义。
Q API Reference
关于javascript - Console.log() 在 Q 中打印 Promise 对象的状态和值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45518510/