如何在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