π浅易 2022-05-04 10:41:27
感谢分享,学到了很多!
建议在简单实现一个createstore函数
的演示部分中补充上reducer
的代码
const reducer = (state = {}, action = {type: 'INIT'}) => {
switch (action.type) {
case 'INCREMENT': {
return Object.assign( {}, { count: ++state.count })
}
default: return { count: 0 };
}
}
// 为了能直接看到count,可以顺便可以修改下render方法的渲染值
const render = () => {
document.body.innerText = store.getState().count;
}
- 共 1 页
- 1
let arr22 = [1, 2, 3, 4, 5, 6, 7];
const find02 = (arr, k) => {
return arr.splice(arr.length - k).concat(arr)
}
第 77 题:旋转数组算法题