慕烟庭风 2022-05-04 13:54:54
写一下自己的理解
// arr : A(牌堆): 底 【1, 。。。。, 13】 顶 // res: B (手里): 底 【】 顶 // 原操作:B顶 => A顶 B顶 => B底 (如果B有多张) // 逆向操作:B底 => B顶 (如果B有多张) A顶 => B顶 const reverse = arr => { const res = []; while (arr.length > 0) { if (res.length) { res.push(res.shift()); } const item = arr.pop(); res.push(item); } return res; }; // 输出 手里牌 // 底 [ 7, 10, 6, 13, 5, 9, 4, 11, 3, 8, 2, 12, 1 ] 顶
慕烟庭风 2022-05-03 15:16:09
4. TouchableHightlight
必须注册 onPress
回调,否则不显示 underlayColor
详情见: facebook/react-native#14908
<TouchableHighlight underlayColor="red"> </TouchableHighlight>
如果不注册 onPress
回调,TouchableHighlight
看起来手指按压时无反应,原因即:
_showUnderlay: function() { - if (!this._isMounted || !this._hasPressHandler()) { + if (!this._isMounted) { return; }
- 共 1 页
- 1
第一次执行栈的同步任务都完成后,接着处理的应该是微任务吧,然后再从宏任务队列里拿一条宏任务到执行栈中,等执行栈中的宏任务处理完,再去清空微任务队列。
第 8 题:setTimeout、Promise、Async/Await 的区别