svg中的textpath无法在IE中运行?

时间:2022-11-20 18:27:44

I see IE display different with firefox, chrome, safari...

我看到IE显示与firefox,chrome,safari有所不同......

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="700" width="1300">
<defs>
    <path id="defsPath0" transform="translate(0, 0)" d="M-25,12 L75,12 M-25,32 L75,32 M-25,52 L75,52 M-25,72 L75,72" />
    <path id="defsPath1" transform="translate(0, 20)" d="M-25,12 L75,12 M-25,32 L75,32 M-25,52 L75,52 M-25,72 L75,72" />
    <path id="defsPath2" transform="translate(0, 40)" d="M-25,12 L75,12 M-25,32 L75,32 M-25,52 L75,52 M-25,72 L75,72" />
    <path id="defsPath3" transform="translate(0, 60)" d="M-25,12 L75,12 M-25,32 L75,32 M-25,52 L75,52 M-25,72 L75,72" />
</defs>
<g>
    <text x="0" y="0" font-family="MS UI Gothic" font-size="15" style="" fill="rgb(0, 0, 0)" fill-rule="nonzero" transform="matrix(1,0,0,1,200,20)">
        <textPath id="textPath_0_0" xlink:href="#defsPath0">1</textPath>
        <textPath id="textPath_0_1" xlink:href="#defsPath1">2</textPath>
        <textPath id="textPath_0_2" xlink:href="#defsPath2">3</textPath>
        <textPath id="textPath_0_3" xlink:href="#defsPath3">4</textPath>
    </text>
</g>

with Firefox, chrome:
1
2
3
4

使用Firefox,chrome:1 2 3 4

But IE:
1
234

但IE:1 234

Please help me ! thank you so much !

请帮我 !非常感谢 !

1 个解决方案

#1


I use javascript make to svg !

我使用javascript make到svg!

Then you should have shown us your Javascript also.

然后你应该向我们展示你的Javascript。

However I suspect I know what the problem is. I am guessing you are using createElement() to create your SVG elements. You need to use createElementNS():

但我怀疑我知道问题是什么。我猜你正在使用createElement()来创建你的SVG元素。您需要使用createElementNS():

document.createElementNS(""http://www.w3.org/2000/svg", "textPath");

#1


I use javascript make to svg !

我使用javascript make到svg!

Then you should have shown us your Javascript also.

然后你应该向我们展示你的Javascript。

However I suspect I know what the problem is. I am guessing you are using createElement() to create your SVG elements. You need to use createElementNS():

但我怀疑我知道问题是什么。我猜你正在使用createElement()来创建你的SVG元素。您需要使用createElementNS():

document.createElementNS(""http://www.w3.org/2000/svg", "textPath");