[转载]Javascript.then()这个⽅法是什么意思?
javascript是什么意思中文翻译1. then()⽅法是异步执⾏。
2. 意思是:就是当.then()前的⽅法执⾏完后再执⾏then()内部的程序,这样就避免了,数据没获取到等的问题。
3. 语法:promise.then(onCompleted, onRejected);
4. 参数
promise必需。Promise 对象。
onCompleted必需。承诺成功完成时要运⾏的履⾏处理程序函数。
onRejected可选。承诺被拒绝时要运⾏的错误处理程序函数。
代码举例:
start() {
super.start();
if (ansport) {
ady.then(() => {
return this.clientSM.start();
});
} else {
ject("no transport attached");
}
}