+
95
-

回答

let inputElement = document.querySelector("#myInput");let composing = false;  // 用于跟踪是否正在输入中文inputElement.addEventListener('compositionstart', function() {    composing = true;});inputElement.addEventListener('compositionend', function() {    composing = false;    triggerInputEvent();});inputElement.addEventListener('input', function() {    if (!composing) {        triggerInputEvent();    }});function triggerInputEvent() {    // 在这里处理输入完成后的逻辑    console.log("Finished Input: " + inputElement.value);}

网友回复

我知道答案,我要回答