svg元素的clientHeight和offsetHeight 在火狐中是0和undefined,在chrome中正常。请问要怎么获取svg的高度呢?<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Title</title></head><body><svg id="svg" viewBox="0,0,50,50" version="1.1" xmlns="http://www.w3.org/2000/svg"> <rect x="0.5" y="0.5" rx="3" ry="3" width="49" height="49" fill="transparent" stroke="black" stroke-width="1"/> <text x="25" y="30" text-anchor="middle" font-size="14px" font-family="Yahei" fill="red">Abc</text></svg><script> let a=document.getElementById('svg').clientHeight; console.log(a);</script></body></html>
添加回答
举报
0/150
提交
取消