摘要: <script> button.addEventListener('click',()=>{ console.log('listener1'); Promise.resolve().then(()=>console.log('micro task1')) }) button.addEventList 阅读全文
posted @ 2020-06-09 23:25 TTtttt5 阅读(1263) 评论(1) 推荐(0) 编辑
摘要: <script> document.body.style.background = 'red'; console.log(1) Promise.resolve().then(()=>{ console.log(2) document.body.style.background = 'yellow'; 阅读全文
posted @ 2020-06-09 22:57 TTtttt5 阅读(252) 评论(0) 推荐(0) 编辑
摘要: http://zhufengpeixun.com/jg-vue/node/async-1.html#%E7%B1%BB%E5%9E%8B%E6%A3%80%E6%B5%8B 阅读全文
posted @ 2020-06-09 22:17 TTtttt5 阅读(94) 评论(0) 推荐(0) 编辑
摘要: // tj async+await = generator +co function co(it){ return new Promise((resolve,reject)=>{ // 异步迭代 需要next函数 function next(r){ let {value,done} = it.nex 阅读全文
posted @ 2020-06-09 22:15 TTtttt5 阅读(203) 评论(0) 推荐(0) 编辑
摘要: //generator 生成器 =》遍历器(需要有一个next方法)=》数组=》类数组 //...原理就是遍历这个对象,将结果放到数组中,这个数据必须得有个遍历器。[...new Set()] for of //[...likeArray] /Array.from(likeArray) const 阅读全文
posted @ 2020-06-09 21:46 TTtttt5 阅读(128) 评论(0) 推荐(0) 编辑
摘要: let promise = new Promise((resolve,reject)=>{ setTimeout(() => { resolve('ok 成功了') }, 10000); }) const wrap = promise=>{ let abort let myP = new Promi 阅读全文
posted @ 2020-06-09 21:20 TTtttt5 阅读(472) 评论(0) 推荐(0) 编辑
摘要: / all 方法 最终返回的是一个promise // 如果全成功了 才算成功 如果一个失败了 就失败了 function isPromise(x) { if((typeof x 'object' && x!==null) || typeof x == 'function'){ if(typeof 阅读全文
posted @ 2020-06-09 20:57 TTtttt5 阅读(157) 评论(0) 推荐(0) 编辑
摘要: let promise2 = new Promise((resolve, reject) => { if (this.status RESOLVED) { setTimeout(() => { try { let x = onFulfilled(this.value); resolvePromise 阅读全文
posted @ 2020-06-09 20:52 TTtttt5 阅读(480) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/weixin_30577801/article/details/102246577 https://www.cnblogs.com/luwei-web/p/10275400.html 阅读全文
posted @ 2020-06-09 10:39 TTtttt5 阅读(224) 评论(0) 推荐(0) 编辑