上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
摘要: function listToTree(list, parentId = null) { const tree = []; for (let i = 0; i < list.length; i++) { if (list[i].parentId parentId) { const node = { 阅读全文
posted @ 2024-01-30 17:32 行走的蒲公英 阅读(16) 评论(0) 推荐(0)
摘要: function throttle(func, ms = 1000) { let canRun = true; return function (...args) { if (!canRun) return; canRun = false; setTimeout(() => { func.apply 阅读全文
posted @ 2024-01-30 17:31 行走的蒲公英 阅读(16) 评论(0) 推荐(0)
摘要: function debounce(func, ms = 1000) { let timer; return function (...args) { if (timer) { clearTimeout(timer); } timer = setTimeout(() => { func.apply( 阅读全文
posted @ 2024-01-30 17:31 行走的蒲公英 阅读(20) 评论(0) 推荐(0)
摘要: 方法一: function format(num) { let str = num + ""; return str .split("") .reverse() .reduce((prev, next, index) => { return (index % 3 ? next : next + ", 阅读全文
posted @ 2024-01-30 17:30 行走的蒲公英 阅读(27) 评论(0) 推荐(0)
摘要: function newFilter(arr, fn) { let newArr = []; for (let i; i < arr.length; i++) { if (fn(arr[i])) { newArr.push(arr[i]); } } return newArr; } 阅读全文
posted @ 2024-01-30 17:29 行走的蒲公英 阅读(22) 评论(0) 推荐(0)
摘要: 话不多说,上代码 function deepClone(obj) { let newObj = null; if (typeof obj "object") { newObj = obj instanceof Array ? [] : {}; for (let i in obj) { newObj[ 阅读全文
posted @ 2024-01-30 17:28 行走的蒲公英 阅读(15) 评论(0) 推荐(0)
摘要: 计算属性(Computed): computed 是基于依赖关系进行缓存的。只有当相关的响应式依赖发生改变时,才会重新求值。适合于执行更复杂的数据操作。 computed 属性是计算出来的,不会对原始数据造成任何副作用。 computed 属性可以具有 setter 和 getter 方法,可以更灵 阅读全文
posted @ 2023-12-28 10:43 行走的蒲公英 阅读(289) 评论(0) 推荐(0)
摘要: 在JavaScript中,this 是一个特殊的变量,它引用了调用对象。它的指向在不同的上下文中有不同的变化。以下是一些常见的 this 指向的情况: 1.全局上下文:在全局作用域中,this 指向全局对象。在浏览器中,这通常是 window 对象。 console.log(this); // wi 阅读全文
posted @ 2023-12-27 14:35 行走的蒲公英 阅读(40) 评论(0) 推荐(0)
摘要: 如何写好代码其实是一个很大的话题,本次仅分享一些自己的经验之谈,有其他idea的欢迎交流 在我看来,写好代码更多的是逻辑思维的体现,而这,紧靠一两次分享是无法提高的,我只能尽可能的将可能可以复制的经验进行分享 本次分享不会涉及太多你使用的框架的具体使用细节,技术选型总是千变万化的,我们需要的是抓住不 阅读全文
posted @ 2023-04-07 15:42 行走的蒲公英 阅读(115) 评论(0) 推荐(1)
摘要: 使用到ahooks里面的 useFullscreen, https://ahooks.js.org/zh-CN/hooks/use-fullscreen/#usefullscreen-demo2 直接上代码了 import { useFullscreen } from 'ahooks'; impor 阅读全文
posted @ 2023-04-07 14:58 行走的蒲公英 阅读(59) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页