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
微任务、宏任务与Event-Loop
ajax是宏任务还是微任务?
The text was updated successfully, but these errors were encountered:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> </head> <body></body> <script src="https://unpkg.com/pubsub-js"></script> <script> const data = { syncNum: 0, asyncNum: 0, }; // 异步 PubSub.subscribe("async", (msg, data) => { console.log('5.异步'); data.asyncNum++; }); // 同步 PubSub.subscribe("sync", (msg, data) => { console.log('1.同步'); data.syncNum++; }); PubSub.publish("async", data); PubSub.publishSync("sync", data); console.log("2.========"); // 模拟请求 Promise.resolve(data).then(({ syncNum, asyncNum }) => { console.log('4.异步微任务同步数值', syncNum); // 1 console.log('4.异步微任务异步数值', asyncNum); // 0 }); setTimeout(() =>{ console.log('6.setTimeout异步宏任务', data.asyncNum) // 1 }) console.log('3.同步任务同步数值', data.syncNum); // 1 console.log('3.同步任务异步数值', data.asyncNum); // 0 </script> </html>
Sorry, something went wrong.
No branches or pull requests
微任务、宏任务与Event-Loop
ajax是宏任务还是微任务?
The text was updated successfully, but these errors were encountered: