摘要:
Map Map是JavaScript的一种数据结构,主要用于有序保存键值对,任何值都可以作为一个键或者值。 Map实现了iterator接口,遵循可迭代协议 1 特点 有序插入/输出 任意值都可以作为键 2 key 键的比较基于sameValueZero算法 在作为键的时候,NaN与NaN是相等的 阅读全文
posted @ 2022-06-21 16:07
IslandZzzz
阅读(435)
评论(1)
推荐(0)
摘要:
interface和type都可以用作ts中限制变量的类型,它们有一些共同点 都能作为限制变量类型的方式 都能被class实现 但也有所区别 interface可以实现声明合并,type不行 interface A { a: string } interface A{ b:string } cons 阅读全文
posted @ 2022-06-21 11:12
IslandZzzz
阅读(250)
评论(0)
推荐(0)
摘要:
type A = { a: number, b: number } type B = { a: number } // 交叉类型, 需要满足A和B的并集 const D: A & B = { a: 1, b: 2 } // 联合类型,需要满足A和B的交集 const E: A | B = { a: 阅读全文
posted @ 2022-06-21 11:07
IslandZzzz
阅读(63)
评论(0)
推荐(0)
摘要:
定义useLazyLoad 思路: 判断图片在视口内就加载,即: 元素距离页面顶部的距离offsetTop < 滚动条高度scrollTop + 视口高clientHeight import { useCallback, useEffect, useState } from 'react' impo 阅读全文
posted @ 2022-06-21 00:20
IslandZzzz
阅读(992)
评论(0)
推荐(0)
摘要:
定义 import { useCallback, useEffect, useRef } from "react" export interface ThrottleRefType { fn: Function, timer?: NodeJS.Timeout } export type Thrott 阅读全文
posted @ 2022-06-21 00:14
IslandZzzz
阅读(969)
评论(0)
推荐(0)
摘要:
定义 import { useCallback, useEffect, useRef } from "react" export interface DebounceRefType { fn: Function, timer?: NodeJS.Timeout } export type Deboun 阅读全文
posted @ 2022-06-21 00:12
IslandZzzz
阅读(1005)
评论(0)
推荐(0)
摘要:
问题 不能将类型“Timeout”分配给类型“number” Type 'Timeout' is not assignable to type 'number'. 解决方案 设置类型为NodeJS.Timeout 清除时使用delete ref.timer + clearTimeout export 阅读全文
posted @ 2022-06-21 00:05
IslandZzzz
阅读(4021)
评论(0)
推荐(0)

浙公网安备 33010602011771号