摘要: lsof -i :3000 kill -9 <PID> 或者一行搞定: lsof -ti :3000 | xargs kill -9 阅读全文
posted @ 2026-05-05 09:45 十三山入秋 阅读(4) 评论(0) 推荐(0)
摘要: 代码 Demo.tsx import MessageContext from "./MessageContext"; import { useContext } from "react"; // // 没有 Context 时的问题: // App 想把消息传给 Level03,必须经过 Level 阅读全文
posted @ 2026-04-20 15:22 十三山入秋 阅读(9) 评论(1) 推荐(0)
摘要: 两种方式: 1. 看文档/源码 鼠标悬停在导入的东西上,看它的定义: interface、type 关键字定义的 → 纯类型 function、const、class 定义的 → 不是 2. 看报错信息 TypeScript 会直接告诉你。比如你遇到的: "LoaderFunctionArgs"是一 阅读全文
posted @ 2026-04-14 00:10 十三山入秋 阅读(8) 评论(0) 推荐(0)
摘要: /** * 提前加载数据 */ export const loadProducts = async (productId: string | number, signal: AbortSignal) => { try { const response = await fetch(`/api/prod 阅读全文
posted @ 2026-04-13 23:19 十三山入秋 阅读(7) 评论(1) 推荐(0)
摘要: 核心结论(必背) 1. () => (<div></div>) 小括号 ( ) = 直接返回里面的内容 → 必须写这个 才能渲染出元素 ✅ 2. () => { <div></div> } 大括号 { } = 只是代码块,不自动返回 → 页面什么都不显示 ❌ 一句话分清 (内容) = 直接 retu 阅读全文
posted @ 2026-04-13 22:00 十三山入秋 阅读(11) 评论(0) 推荐(0)
摘要: 我给你一次性讲透,ring 是 Tailwind 里最常用、最漂亮的聚焦样式,专门用来替代浏览器原生丑丑的边框。 一句话解释 ring = 给元素加一层「外发光光环」 不是边框,是在边框外面的一层柔和光晕,苹果风格、高级感全靠它。 1. focus:ring-2 到底是什么? focus: 只有鼠标 阅读全文
posted @ 2026-04-13 19:41 十三山入秋 阅读(15) 评论(2) 推荐(0)
摘要: 错误处理策略 fetch("https://api.example.com/products") .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(err 阅读全文
posted @ 2026-04-13 17:53 十三山入秋 阅读(5) 评论(0) 推荐(0)
摘要: 我用最简单、最直白、最贴近你这段代码的方式,帮你快速回忆 Promise! 保证你马上看懂! 1. Promise 是啥? 一句话: Promise 就是“承诺”:现在没结果,未来会给你结果。 异步操作(定时器、接口请求)专用 不会阻塞代码 2. 你这段代码拆解 function sleepAsyn 阅读全文
posted @ 2026-04-13 01:14 十三山入秋 阅读(7) 评论(6) 推荐(0)
摘要: const updateItem = (updates: Partial<CartItem>) => { return produce(draft => { // Object.assign(draft, updates) for (const key in updates) { (draft as 阅读全文
posted @ 2026-04-12 13:07 十三山入秋 阅读(6) 评论(0) 推荐(0)
摘要: 这个报错 Expected ";" but found "User" 并不是 TypeScript 的类型语法错了,而是 React 组件里不能直接写 interface! 我直接给你指出两个错误,并告诉你为什么报错,一步到位修复👇 一、第一个错误(报红的根本原因) 在 React 函数组件内部, 阅读全文
posted @ 2026-04-12 12:03 十三山入秋 阅读(6) 评论(1) 推荐(0)