typescript - typescript 转换错误以获取输入值

标签 typescript casting syntax-error

我一直无法弄清为什么会发生此错误,并且似乎没有其他人可以分享我的错误,有何见解?这是我第一次使用TypeScript。

告诉我您是否需要更多信息或编码示例。

最佳答案

它是.tsx文件吗?如果是这样,则可能是解析问题-<HTMLInputElement>被识别为开放的React标记,而不是TS类型的转换表达式。尝试使用as强制转换:

(document.getElementById('ulvl') as HTMLInputElement).value

关于typescript - typescript 转换错误以获取输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61341492/

相关文章:

C# 如何将点转换为 vector2?

amazon-web-services - Talend S3 CSV转为Redshift处理丢失的数据

node.js - 为什么 request.query 不再是 'any' 了? express request.query typescript 错误

angular - 如何在 Angular 2中使用 typescript 从文本框中获取值(value)

c# - "Input string was not in a correct format."C#

mongodb - 无法从 `[]string` 断言类型 `[]interface{}`

linux - Bash : syntax error operand expected “=” , in assignment statement in a for loop

flutter - 声明预期变量类型导致错误: type '(Map<String, dynamic>) => University' is not a subtype of type '(dynamic) => dynamic' of 'f'

javascript - 如何在 javascript 中创建动态内插字符串?

typescript - 逐步扩展对象的类型