摘要: 1. 实现一个sleep函数一秒后console.log一次 <html> <head> <title>HELLO</title> </head> <body> <h1>HELLO</h1> <script> const sleep = async (seconds) => new Promise( 阅读全文
posted @ 2025-12-30 11:43 龚思凯1 阅读(20) 评论(0) 推荐(0)
摘要: 优化前的代码 <template> <p @click="helloFunc" >Hello</p> <div v-if="hello 1" style="background-color: blue;" > <img src="https://placeholder.im/3000x2000.pn 阅读全文
posted @ 2025-12-29 16:45 龚思凯1 阅读(5) 评论(0) 推荐(0)
摘要: 将window.console.log置为空函数 if (process.env.NODE_ENV 'production') { window.console.log = () => {}; } 阅读全文
posted @ 2025-12-29 11:30 龚思凯1 阅读(6) 评论(0) 推荐(0)
摘要: dns-prefetch 只做 1 件事:提前完成「DNS 解析」+ 缓存 <link rel="dns-prefetch" href="https://hello.com"> preconnect 做 3 件事:提前完成「DNS 解析」+「TCP 三次握手」+「TLS 加密协商(HTTPS 场景) 阅读全文
posted @ 2025-12-27 17:00 龚思凯1 阅读(6) 评论(0) 推荐(0)
摘要: async和defer同时出现则只渲染async 以下内容defer最后展示 <html> <head> <script async src="./async.js"></script> <script defer src="./defer.js"></script> <script src="./ 阅读全文
posted @ 2025-12-27 15:26 龚思凯1 阅读(5) 评论(0) 推荐(0)
摘要: 白屏时间 <script> const observer = new PerformanceObserver((list) => { const entries = list.getEntries(); for (const entry of entries) { if (entry.name 'f 阅读全文
posted @ 2025-12-25 16:56 龚思凯1 阅读(7) 评论(0) 推荐(0)
摘要: 结论 mkdir koa-demo && cd koa-demo npm init -y npm install koa // 1. 引入Koa模块(CommonJS规范,Node.js默认支持) const Koa = require('koa'); // 2. 创建Koa应用实例 const a 阅读全文
posted @ 2025-11-13 17:44 龚思凯1 阅读(39) 评论(0) 推荐(0)
摘要: 函数组件 // 复用按钮组件 function Button({ text, onClick, type = "default" }) { const styles = { primary: { backgroundColor: "blue", color: "white" }, default: 阅读全文
posted @ 2025-11-11 17:29 龚思凯1 阅读(9) 评论(0) 推荐(0)
摘要: 示例图 BFS示例代码 function bfsShortestPath(graph, start, end) { const queue = [[start]]; const visited = new Set([start]); while (queue.length > 0) { const 阅读全文
posted @ 2025-11-10 17:00 龚思凯1 阅读(37) 评论(0) 推荐(0)
摘要: 函数组件 // src/components/Hello1.jsx import { useState } from 'react' function Hello1 (props) { const [ hello1, setHello1 ] = useState('world1') setTimeo 阅读全文
posted @ 2025-11-07 10:33 龚思凯1 阅读(4) 评论(0) 推荐(0)