会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
苏沐
「 随 心 」
博客园
首页
新随笔
联系
订阅
管理
1
2
3
4
5
下一页
2025年8月25日
React 列表定时轮询刷新+滚动加载
摘要: 1、安装依赖 npm i antd npm i react-infinite-scroll-component 2、DataList.tsx import React, { useEffect, useRef } from "react"; import { Spin } from "antd";
阅读全文
posted @ 2025-08-25 16:55 苏沐~
阅读(17)
评论(0)
推荐(0)
2025年7月17日
React 可拖拽组件MovableBox封装
摘要: npm i react-spring 一、拖拽组件封装 import React, { useState, useRef, useEffect, useCallback } from "react"; import { useSpring, animated } from "@react-sprin
阅读全文
posted @ 2025-07-17 15:36 苏沐~
阅读(32)
评论(0)
推荐(0)
2025年7月15日
React MoveBoxComponent
摘要: npm i react-spring import React, { useState, useRef, useEffect } from "react"; import { useSpring, animated } from "@react-spring/web"; interface IPos
阅读全文
posted @ 2025-07-15 09:18 苏沐~
阅读(9)
评论(0)
推荐(0)
2025年6月25日
React useSyncExternalStore 封装 useWindowSize、useURLParams
摘要: useWindowSize // useWindowSize.ts import { useRef, useCallback, useSyncExternalStore } from "react"; export function useWindowSize() { const cachedVal
阅读全文
posted @ 2025-06-25 12:06 苏沐~
阅读(13)
评论(0)
推荐(0)
2025年6月24日
React useSyncExternalStore 封装 localStorage 实现跨页面同步状态
摘要: // useLocalStorage.ts import { useSyncExternalStore, useCallback } from "react"; // 使用泛型提升类型安全 export function useLocalStorage<T>( key: string, initia
阅读全文
posted @ 2025-06-24 15:51 苏沐~
阅读(40)
评论(0)
推荐(0)
React useTransition 和 useDeferredValue 使用
摘要: useTransition 适用场景 1. 数据加载:在数据加载过程中,我们可以使用 useTransition 在更新 UI 之前显示一个加载指示器,从而优化用户体验。 2. 动画和过渡效果:在组件状态更新时,useTransition 可以让我们更好地控制动画和过渡效果的触发时机。 useDef
阅读全文
posted @ 2025-06-24 11:19 苏沐~
阅读(52)
评论(0)
推荐(0)
2025年6月23日
React 使用 forwardRef 和 useImperativeHandle —— 父组件调用子组件事件
摘要: import React, { useState, useImperativeHandle, forwardRef, useRef, Ref, } from "react"; interface IProps { readonly List?: Array<any>; readonly fun?:
阅读全文
posted @ 2025-06-23 15:16 苏沐~
阅读(9)
评论(0)
推荐(0)
2025年6月10日
React 滚动监听 和 tab 切换
摘要: Tabs组件 //Tabs.tsx import React from "react"; import classNames from "classnames"; import "./index.scss"; interface IProps { readonly tabs: Array<Itab>
阅读全文
posted @ 2025-06-10 18:07 苏沐~
阅读(35)
评论(0)
推荐(0)
2025年6月4日
前端RSA加密方法jsencrypt encryptlong以及遇到的问题
摘要: 注意: 加密的对象一定要是字符串 如果你加密的是字符串且数据少 则npm i jsencrypt 即可 如果加密的是对象并且数据多 比如含有token 用npm i encryptlong -S npm i jsencrypt加密长对象将返回false 或者报Message too long for
阅读全文
posted @ 2025-06-04 17:50 苏沐~
阅读(399)
评论(0)
推荐(0)
2025年5月22日
通过moment转化new Date、时间戳、格式化时间
摘要: // 安装和引入moment // npm install moment --save # npm // yarn add moment # Yarn // import moment from 'moment' //获取当前moment时间 let currentMoment = moment()
阅读全文
posted @ 2025-05-22 15:23 苏沐~
阅读(551)
评论(0)
推荐(0)
1
2
3
4
5
下一页
公告