let timeoutId1 =setTimeout(()=>{console.log("这段代码不会执行");},1000);let timeoutId2 =setTimeout(()=>{console.log("这段代码会执行");},1000);clearTimeout(timeoutId1);
# 输出结果这段代码会执行
3、注意事项
如果定时器已经触发,调用 clearTimeout 函数不会有任何效果
let timeoutId1 =setTimeout(()=>{console.log("定时器 1 执行了");},1000);let timeoutId2 =setTimeout(()=>{console.log("取消定时器 1");clearTimeout(timeoutId1);},2000);
# 输出结果定时器 1 执行了
取消定时器 1
如果定时器已经取消,调用 clearTimeout 函数不会有任何效果
let timeoutId1 =setTimeout(()=>{console.log("这段代码不会执行");},1000);let timeoutId2 =setTimeout(()=>{console.log("这段代码会执行");},1000);clearTimeout(timeoutId1);clearTimeout(timeoutId1);
setTimeout 函数与 setInterval 函数共享同一个 ID 池,在技术上可以混用 clearTimeout 函数和 clearInterval 函数,但是,为了清楚起见,应该避免这样做
let timeoutId1 =setTimeout(()=>{console.log("这段代码不会执行");},1000);let timeoutId2 =setTimeout(()=>{console.log("这段代码会执行");},1000);clearInterval(timeoutId1);
按键序列常用示例
按键编码
基础按键对应编码
A-Z 原字符即可
KeyCodeSHIFTCTRL^ALT%
其他按键
KeyCodeBACKSPACE{BACKSPACE}, {BS}, or {BKSP}BREAK{BREAK}CAPS LOCK{CAPSLOCK}DEL or DELETE{DELETE} or {DEL}DOWN ARROW{DOWN}END{END}ENTER{ENTER} or ~ESC{ESC}HELP{HEL…
导言如上图所示,在编译器附加选项(全局)里添加--specsnano.specs,告诉编译器使用newlib-nano替代newlib去编译代码。
newlib vs. newlib-nano
newlib 是 GNU ARM 工具链默认的 C 标准库,功能完整,但体积较大…