getHtmlFontSize(): number {
let htmlFontSize = getComputedStyle(window.document.documentElement)['font-size']
//以上方法返回的font-size会带单位px,如果不想要px可以做一下处理
return +htmlFontSize.slice(0, htmlFontSize.indexOf('px'))
}
console.log(getHtmlFontSize()) //33.3333
获取html的字体大小
最新推荐文章于 2023-10-07 09:39:40 发布