属性 'r' 在类型 'HTMLElement' 上不存在

Property 'r' does not exist on type 'HTMLElement'

我正在尝试获取圆形 svg 元素的半径,但 vs 代码出现错误:

实际代码:

const circle = document.getElementById('progress_circle');
const radius = circle.r.baseVal.value;

错误:

Property 'r' does not exist on type 'HTMLElement'.js(2339)

我正在使用 svelte、ts 和 vs code 我也是网络开发的新手

感谢@aerial301

,我终于找到了解决方案
const circle = document.getElementById('progress_circle');
const radius = +circle.getAttribute('r');

参考:Changing properties of SVG circle in HTML5/JS