09 2021 档案
摘要:一、概念 React 性能优化的起因: 在React中,默认情况下,当父组件重渲染时,子组件也会重渲染。 在React中,子组件默认随父组件更新而更新。 React 性能优化的方向:通过缓存,减少渲染次数、减少重复计算。 React Hook性能优化的总结:memo缓存组件、useCallback缓
阅读全文
摘要:function unique(arr) { let res = []; for (let i = 0; i < arr.length; i++) { let current = arr[i]; if (res.indexOf(current) -1) res.push(current); } re
阅读全文
摘要:class Event { constructor() { // 存储事件的数据结构 // 为了查找迅速,使用了对象(字典) this._cache = {}; } // 绑定 on(type, callback) { // 为了按类查找方便和节省空间, // 将同一类型事件放到一个数组中 // 这
阅读全文
摘要:let array = [ { id: 1, name: "001", children: [ { id: 2, name: "002", }, ], }, { id: 3, name: "003", children: [] }, ]; function getFlatArr(arr) { ret
阅读全文
摘要:v-model是语法糖: <input v-model="sth" /> <input v-bind:value="sth" v-on:input="sth = $event.target.value" /> <input :value="sth" @input="sth = $event.targ
阅读全文

浙公网安备 33010602011771号