在我andrio手机上测试有效 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> </style> </head> <body> <div id="div">rfgdfdgdghfgsgfg</div> <div id="font"></div> </body> <script> window.onload = function(){ const div = document.getElementById('div'); const font = document.getElementById('font'); // console.dir(div.style.fontFamily); function getFontFamily(elem) { var computedStyles = window.getComputedStyle(elem); console.log(computedStyles['font-family']); font.innerText = computedStyles['font-family']; } getFontFamily(div); } </script> </html>
在我andrio手机上测试有效