只需要将HTMLElement强制转换为HTMLInputElement即可
举个栗子
let inputValue = (document.getElementById('input') as HTMLInputElement).value;
本文介绍了一种简单的方法来获取HTML页面中输入框的值,只需通过ID选择器找到元素并将其类型转换为HTMLInputElement。
只需要将HTMLElement强制转换为HTMLInputElement即可
举个栗子
let inputValue = (document.getElementById('input') as HTMLInputElement).value;

被折叠的 条评论
为什么被折叠?