摘要:
class MyCache { constructor(isLocal = true) { this.storage = isLocal ? localStorage : sessionStorage } setItem(key, value) { if (typeof (value) 'objec 阅读全文
posted @ 2023-01-29 17:03
技术杨
阅读(21)
评论(0)
推荐(0)
摘要:
参数: {number} number:要格式化的数字 {number} decimals:保留几位小数 {string} dec_point:小数点符号 {string} thousands_sep:千分位符号 export const moneyFormat = (number, decimal 阅读全文
posted @ 2023-01-29 17:02
技术杨
阅读(88)
评论(0)
推荐(0)
摘要:
export const uuid = () => { const temp_url = URL.createObjectURL(new Blob()) const uuid = temp_url.toString() URL.revokeObjectURL(temp_url) //释放这个url 阅读全文
posted @ 2023-01-29 17:00
技术杨
阅读(126)
评论(0)
推荐(0)
摘要:
export const smoothScroll = element =>{ document.querySelector(element).scrollIntoView({ behavior: 'smooth' }); }; 示例: smoothScroll('#target'); // 平滑滚 阅读全文
posted @ 2023-01-29 16:59
技术杨
阅读(50)
评论(0)
推荐(0)
摘要:
用 Set 数据结构 对于对象数组,可以使用 Set 数据结构对其中的对象进行去重。代码如下: let arr = [{name: 'apple'}, {name: 'orange'}, {name: 'apple'}]; let newArr = Array.from(new Set(arr.ma 阅读全文
posted @ 2023-01-29 16:56
技术杨
阅读(48)
评论(0)
推荐(0)
浙公网安备 33010602011771号