简体   繁体   English

TS 2540:无法分配给样式,因为它是只读属性

[英]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 设为只读有点奇怪,因为它可以写入...

vim 错误 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设为只读有点奇怪,因为可以将其写入...

vim错误 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.

相关问题 错误 TS2540:无法分配给“i”,因为它是常量或只读属性 - error TS2540: Cannot assign to 'i' because it is a constant or a read-only property TS2540:无法分配给“矩阵”,因为它是只读属性 - TS2540: Cannot assign to 'matricule' because it is a read-only property 无法分配给“fromDate”,因为它是只读属性。ts - Cannot assign to 'fromDate' because it is a read-only property.ts 角度2 | 无法分配给数组,因为它是常量或只读属性 - Angular 2 | cannot assign to array because it is a constant or a read-only property 无法分配给“total”,因为它是一个常量或只读属性 - Cannot assign to 'total' because it is a constant or a read-only property 角度无法分配给“名称”,因为它是常量或只读属性 - Angular Cannot assign to 'name' because it is a constant or a read-only property Nuxt TypeScript:无法分配给“名称”,因为它是只读属性 - Nuxt TypeScript: Cannot assign to 'name' because it is a read-only property 无法分配给“状态”,因为它是常量或只读属性 - Cannot assign to 'state' because it is a constant or a read-only property 无法分配给“ initialState”,因为它是只读属性 - Cannot assign to 'initialState' because it is a read-only property 无法分配给“布尔”,因为它是常量或只读属性 - Cannot assign to 'Boolean' because it is a constant or a read-only property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM