We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
层面上的理解:
Promise是一个类,有3个状态分别是:等待态(默认) 成功态 失败态
Promise
打个比方比如承诺要给女朋友买一个礼物,一开始先承诺下来(等待态),买了(就是成功),你会让她高兴(就是结果),你不买了(就是失败),你的选择会得到不同的结果。
简单体会:
let promise = new Promise((resolve,reject) => { reject('参数') }).then(data =>{ //成功 console.log(data) },err =>{ //失败 console.log('err',err) })
每个promise实例都有一个.then方法。resolve(成功),reject(失败)。 resolve,reject是自己定义的,你需要他成功或者失败,首先要看自己调用的是谁?
promise
.then
resolve
reject
resolve,reject
(重点);一旦成功了就不能失败。
如果你手动抛出一个异常那就注定会进失败的结果了。
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: