会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
是桂
life begins at the end of your comfort zone
博客园
首页
新随笔
联系
管理
订阅
上一页
1
2
3
4
5
6
7
8
9
10
···
14
下一页
2020年7月10日
promise链式调用的应用
摘要: then在链式调用时,会等前一个then或者函数执行完毕,返回状态,才会执行回调函数。 (1)代码顺序执行,第一步调用了函数cook ,cook执行返回了一个promise,promise返回的是成功状态,即resolve('鸡蛋炒饭'),那么参数“'鸡蛋炒饭'”会传递给下一个then。 (2)第一
阅读全文
posted @ 2020-07-10 22:09 是桂
阅读(1837)
评论(0)
推荐(0)
2020年7月9日
promise的信任问题&控制反转
摘要: //信任问题 //第三方的某个库 function method(cb){ setTimeout(function(){ cb && cb(); //这个库的bug:函数被多调用了一次 cb && cb(); },1000) } //promise一旦被确定为成功或者失败,就不能再被更改 funct
阅读全文
posted @ 2020-07-09 01:16 是桂
阅读(504)
评论(0)
推荐(0)
2020年7月8日
promise加载图片
摘要: 实现一个图片的加载;设置第一张图片加载1s之后加载第二张图片: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>2-4编程练习</title> </head> <body> <script> //获取body元素 let el
阅读全文
posted @ 2020-07-08 01:38 是桂
阅读(484)
评论(0)
推荐(0)
ES6 promise的应用
摘要: html部分 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewprot" content="width=device-width,initial-scale=1.0" /> <meta http-equiv="
阅读全文
posted @ 2020-07-08 00:20 是桂
阅读(272)
评论(0)
推荐(0)
2020年7月4日
promise例题
摘要: let promise = new Promise(resolve => { console.log('Promise'); resolve(); }); promise.then(function(){ console.log('resolved'); }); console.log('hello
阅读全文
posted @ 2020-07-04 23:53 是桂
阅读(154)
评论(0)
推荐(0)
回调与Promise
摘要: Promise 对象就是用于表示一个异步操作的最终状态(成功或失败)。它的流程就是在什么状态下需要执行什么样的操作。 resolve简单理解就是一步操作执行成功后的回调函数 then是Promise对象上的一个方法,它最多需要有两个参数:表示异步操作执行后的回调函数(其实就是resolve和reje
阅读全文
posted @ 2020-07-04 23:10 是桂
阅读(491)
评论(0)
推荐(0)
2020年6月30日
ES6扩展——数组的新方法(Array.from、Array.of、Array.fill、Array.includes、keys values entries 、find)
摘要: 1、Array.from(objec,回调函数)将一个ArrayLike对象或者Iterable对象(类数组对象)转换成一个数组 1)该类数组对象必须具有length属性,用于指定数组的长度。如果没有length属性,那么转换后的数组是一个空数组 2)该类数组对象的属性名必须为数值型或字符串型的数字
阅读全文
posted @ 2020-06-30 03:19 是桂
阅读(136)
评论(0)
推荐(0)
2020年6月29日
数组的扩展运算符应用(十个随机数)
摘要: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> //扩展运算符,可以将一个数组转为用逗号分隔的参数序列. //完成:随机产生十个整数,放入数组中,对这个数组进行降
阅读全文
posted @ 2020-06-29 01:05 是桂
阅读(184)
评论(0)
推荐(0)
2020年6月28日
生成器函数的调用
摘要: Q: 为啥fn()调用不了函数?而arr=[...fn()]却运行了啊?不是next才行? function*fn(){ console.log(1); yield 1+1; console.log(2); yield 2-2; } // fn(); const arr=[...fn()]; con
阅读全文
posted @ 2020-06-28 01:47 是桂
阅读(445)
评论(0)
推荐(0)
2020年6月27日
ES6扩展——数组扩展
摘要: 1、结合扩展运算符使用。通过扩展运算符,在调用函数的时候,把一个数组展开,然后作为这个函数的参数 //结合扩展运算符使用 function foo(a,b,c){ console.log(a); //1 console.log(b); //3 console.log(c); //2 } //通过扩展
阅读全文
posted @ 2020-06-27 02:54 是桂
阅读(113)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
10
···
14
下一页
公告