[英]TS 2540: Cannot assign to style because it is a read-only property
I am creating a textarea
element in my TSX markup, and the TS typechecker in Vim complains 2540: Cannot assign to style because it is a read-only property
.我正在我的 TSX 标记中创建一个textarea
元素, Vim 中的TS 类型检查器抱怨2540: Cannot assign to style because it is a read-only property
。 Having textarea.style be read-only is a bit weird, given that it can be written to ...将 textarea.style 设为只读有点奇怪,因为它可以写入...
How can I make the error message disappear?如何使错误消息消失? Should I cast the input
variable in my code to something else?我应该将代码中的input
变量转换为其他变量吗?
I solved it by using:我通过使用解决了它:
input.setAttribute('style', 'white-space: pre; position: absolute; left: -9999px;');
Apparently "TypeScript does not have a style property on Element."显然“TypeScript 在 Element 上没有样式属性。” as was mentioned in a related Stackoverflow answer .正如相关的 Stackoverflow 回答中提到的那样。
I am creating a textarea
element in my TSX markup, and the TS typechecker in Vim complains 2540: Cannot assign to style because it is a read-only property
.我在TSX标记中创建了一个textarea
元素,而Vim中的TS typechecker抱怨2540: Cannot assign to style because it is a read-only property
。 Having textarea.style be read-only is a bit weird, given that it can be written to ...将textarea.style设为只读有点奇怪,因为可以将其写入...
How can I make the error message disappear?如何使错误消息消失? Should I cast the input
variable in my code to something else?我应该将代码中的input
变量转换为其他变量吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.