我试图找出承诺,我现在很难过。 这里是我的例子不工作:JavaScript承诺蓝鸟跳过示例“then”
<html>
<head>
<title>test page</title>
</head>
<body>
<script type="text/javascript" src="bluebird.js"></script>
<script type="text/javascript" >
function doTheThing() {
return new Promise (function (resolve, reject) {
setTimeout(function(){alert("2");},1000)
alert("1");
});
}
doTheThing().then(
function() {
alert("3");
}, function(error) {
alert("5");
}
);
</script>
</body>
</html>
这提醒“1”,那么“2”,就是这样。
为什么“3”从未提醒过?为什么then()根本不执行?
因为您的承诺既没有解决也没有被拒绝? –