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 標準庫,功能完整,但體積較大…