【发布时间】:2021-01-22 08:46:37
【问题描述】:
我在 TSX 标记中创建了一个 textarea 元素,而 TS typechecker in Vim 抱怨 2540: Cannot assign to style because it is a read-only property。将 textarea.style 设为只读有点奇怪,因为它可以写入...
【问题讨论】:
-
我什至不知道这是否有效。我只在样式图中分配了属性。所以在这里可以使用例如
Object.assign(input.style, { whiteSpace: 'pre', position: 'absolute', left: '-9999px' }) -
@H.B.当然,这是一种方式。不过有点常见。显然不推荐使用字符串(根据 MDN):developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/…
标签: typescript