草庐IT

shortAfterLongFunc

全部标签

javascript - promise 解决后如何从 Promise 对象中获取值

请注意这是一个人为的例子。functionlongFunc(){vardeferred=$.Deferred();setTimeout(function(){console.log("longfunccompleted");deferred.resolve("hello");},3000);returndeferred.promise();}functionshortAfterLongFunc(x){console.log('shortfunccompletedwithvalue:'+x);return{a:x};}processFurther(longFunc().then(shor