【发布时间】:2019-02-07 17:38:00
【问题描述】:
我下载了 pro fontawesome 文件以在我的网络应用程序中使用。我无法使用 CDN。我已正确插入 all.js 文件,因为它在 ie11 和所有其他浏览器中运行良好。我需要它也可以在 ie9 中工作。在 ie9 中使用 CDN 确实可以工作,但我无法使用 CDN 部署站点。有什么建议么?
【问题讨论】:
标签: internet-explorer-9 font-awesome
我下载了 pro fontawesome 文件以在我的网络应用程序中使用。我无法使用 CDN。我已正确插入 all.js 文件,因为它在 ie11 和所有其他浏览器中运行良好。我需要它也可以在 ie9 中工作。在 ie9 中使用 CDN 确实可以工作,但我无法使用 CDN 部署站点。有什么建议么?
【问题讨论】:
标签: internet-explorer-9 font-awesome
根据您的描述,我尝试下载字体真棒文件并在我的应用程序中使用。在IE9浏览器中,使用all.js时,会显示“Unable to get property 'add' of undefined or null reference”的错误。这个问题与 IE9 不支持 classList 有关,所以我们需要像 classList.js 这样的 polyfill。然后,您可以使用 font awesome 文件参考,而不是使用 CDN 参考。
这样的代码:
<head>
<title>Font Awesome 5 Icons</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link href="fontawesome/css/all.css" rel="stylesheet" />
<script src="classList.min.js"></script> <!--https://cdnjs.cloudflare.com/ajax/libs/classlist/1.2.20171210/classList.min.js-->
<script src="polyfill.classList.min.js"></script> <!--https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js-->
<script src="fontawesome/js/all.js"></script>
</head>
<body>
<h1>fas fa-tty</h1>
<i class='fas fa-tty'></i>
<i class='fas fa-tty' style='font-size:24px'></i>
<i class='fas fa-tty' style='font-size:36px'></i>
<i class='fas fa-tty' style='font-size:48px;color:red'></i>
<br>
<span style="font-size: 3em; color: Tomato;">
<i class="fas fa-igloo"></i>
</span>
<span style="font-size: 48px; color: Dodgerblue;">
<i class="fas fa-igloo"></i>
</span>
<span style="font-size: 3rem;">
<span style="color: Mediumslateblue;">
<i class="fas fa-igloo"></i>
</span>
</span>
</body>
结果(使用 F12 更改为 IE 9):
【讨论】: