如何在Windows上运行的Node.js上使用承诺?对于我的生活中,我似乎无法得到任何例如工作...在Windows上使用Node.js上的承诺
例如这样的事情不工作:
var pinput = new Promise(
function(fulfillPromise, breakPromise) {
var btn = document.getElementById("button");
var txt = document.getElementById("txt");
btn.onclick = function() {
fulfillPromise(txt.value);
}
}
);
pinput.whenOnly(function(value) { alert(value); });
扔在要求并没有帮助:
Promise = require('promise');
我得到的是两种:
ReferenceError: promise is not defined
或
Error: Cannot find module 'Promise'
我似乎无法找到从最新API的承诺要么...(http://nodejs.org/docs/latest/api/)
我是不解。
您确定诺基亚模块实际上是否包含在Node.js内核中?我相信它不是。也许你想要一个像https://github.com/kriszyp/node-promise这样的库。 – pimvdb