Ts Js input賦值報錯The property 'value' does not exist on value of type 'HTMLElement'解決辦法

最近做ionic項目,遇到了需要給input賦值的操作,結果報錯: 解決辦法: 即:const inputContant = (document.getElementById('suggestId') as HTMLInputElement); 原因是HTMLElement返回自getElementById()實際上是HTMLInputElement從其繼承的實例,因爲傳遞的是輸入元素的ID。同樣
相關文章
相關標籤/搜索