最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Does path.getTotalLength work for text svg? - Stack Overflow

matteradmin8PV0评论

I'm trying to get the path length for the stroke of a SVG text element and I'm getting a path.getTotalLength is not a function error in my console. When I look up getTotalLength, I see that it's been depreciated? It looks like it has something to do with the shift from SVG1 to SVG2? Is this correct?

I'm trying to get the path length for the stroke of a SVG text element and I'm getting a path.getTotalLength is not a function error in my console. When I look up getTotalLength, I see that it's been depreciated? It looks like it has something to do with the shift from SVG1 to SVG2? Is this correct?

Share Improve this question edited Nov 24, 2020 at 10:25 ashleedawg 21.7k9 gold badges81 silver badges117 bronze badges asked Apr 4, 2017 at 5:30 Aslan FrenchAslan French 5432 gold badges8 silver badges23 bronze badges 2
  • I don't think it never did have this method... – Kaiido Commented Apr 4, 2017 at 6:01
  • What do you think the total length of text is? How would you calculate it? – Robert Longson Commented Apr 4, 2017 at 7:13
Add a ment  | 

1 Answer 1

Reset to default 5

It has not been deprecated. In SVG 1.1, getTotalLength() is only available on the <path> element.

In SVG 2, which browsers are still in the process of implementing (so you can't rely on it yet), getTotalLength() is available on all shape elements, but not including text elements.

Post a comment

comment list (0)

  1. No comments so far