下面是我尝试使用TypeScript重新创建的一小段SVG代码。
<svg>
<switch>
<g requiredFeatures="http://www.w3.org/Graphics/SVG/feature/1.2/#TextFlow">
<textArea width="200" height="auto">
Text goes here
</textArea>
</g>
<foreignObject width="200" height="200"
requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
<p xmlns="http://www.w3.org/1999/xhtml">Text goes here</p>
</foreignObject>
<text x="20" y="20">No automatic linewrapping.</text>
</switch>
在大多数情况下,我可以正常工作,但是我不确定如何将文本插入到TextArea (和文本)元素中。这是我想要做的:
const textArea = document.createElementNS(this.xmlns, 'textArea');
textArea.setAttributeNS(null, 'width', '200');
textArea.setAttributeNS(null, 'height', 'auto');
//textArea.setAttributeNS(null, 'value', text);
textArea.innerHTML('Text goes here');TypeScript一点也不喜欢innerHTML语句。它给了我一个错误:不能调用类型缺少调用签名的表达式。类型“String”没有兼容的调用签名。
我不确定这是什么意思,我如何才能修复它?在某个地方,我看到一个帖子,说只需要设置文本的“值”,我试过了,但它不显示这种情况下的文本,它只是成为另一个参数。
提前感谢您能提供的任何建议。
https://stackoverflow.com/questions/51141996
复制相似问题