为什么我无法获取 cx 和 cy 的值?它打印一些数组。我只需要 2 个值
<!DOCTYPE html>
<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg">
<circle cx="100" cy="100" r="50" fill="red" id="cir"/>
</svg>
<script>
console.log(document.getElementById("cir").cx);
console.log(document.getElementById("cir").cy);
</script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
和属性是cx对象,而不是字符串或数字。cySVGAnimatedLength
要获取 的实际值cx,您需要执行以下操作:
cx.baseVal.value
Run Code Online (Sandbox Code Playgroud)
cx.baseVal.value
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2419 次 |
| 最近记录: |