直接上代码~
onFocusNextInput(e: any) {
const allInputElements = document.querySelectorAll(
".form input[type='text']:not([disabled])"
);
const currentIndex = Array.prototype.indexOf.call(
allInputElements,
e.target
);
if (currentIndex < allInputElements.length) {
(allInputElements[currentIndex + 1] as HTMLElement)?.focus();
}
}