path.getTotalLength 是否适用于文本 svg? [英] Does path.getTotalLength work for text svg?

查看:41
本文介绍了path.getTotalLength 是否适用于文本 svg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 SVG 文本元素笔划的路径长度,但在控制台中出现 path.getTotalLength is not a function 错误.当我查找 getTotalLength 时,我看到它已经折旧了?好像跟从SVG1到SVG2的转变有关系吧?这是正确的吗?

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?

推荐答案

尚未弃用.在 SVG 1.1 中,getTotalLength() 仅在 元素上可用.

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

在 SVG 2 中,哪些浏览器仍在实现中(因此您还不能依赖它),getTotalLength() 可用于所有形状元素,但不包括文本元素.

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.

这篇关于path.getTotalLength 是否适用于文本 svg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆