是否可以添加在此承诺执行者内解决某些承诺后执行的代码?
它看起来像这样:
var loading = new Promise((resolve, reject) => {
app.initialize();
loading.then(/* some extra code */); //loading is undefined
resolve(app);
});
但是这样做,loading
似乎尚未定义。
答案 0 :(得分:4)
简短的回答是否定的。有什么问题:
const loading = new Promise((resolve, reject) => {
app.initialize();
resolve(app);
}).then(app => {
// something else.
})