以下是我遇到问题的代码
for (var j = 0; j < 3; j++) {
console.log("for loop"+j);
Data.getById(item)
.then(function (data) {
console.log("then J"+j);
},
function (error) {
alert(JSON.stringify(error));
});
}
当我运行代码its printing in console for loop 1,for loop 2,for loop 3 first then printing then J 3,then J 3,then J 3 three times
但我希望它应该打印for loop 1 , then j 1, for loop 2 then j 2,for loop 3 , then j 3
订单