我一直遵循Font Awesome指南如何使用他们的工具包,但是当我在我的body
标签末尾插入这段代码时,我得到了一个错误,并且我不能使用任何图标。
<script src="https://kit.fontawesome.com/a4c00a89bc.js" crossorigin="anonymous"></script>
下面是完整的HTML文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="icon" href="imgs/favicon.ico" />
<link rel="apple-touch-icon" href="imgs/logo192.png" />
<link rel="stylesheet" type="text/css" href="scss/main.css">
<title>My title</title>
</head>
<body>
<div>Facebook<i class="fab fa-facebook"></i></div>
<script src="https://kit.fontawesome.com/a4c00a89bc.js" crossorigin="anonymous"></script>
</body>
</html>
下面是错误消息:
Access to script at 'https://kit.fontawesome.com/a4c00a89bc.js' from origin 'http://localhost:63342' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
GET https://kit.fontawesome.com/a4c00a89bc.js net::ERR_FAILED
有什么想法吗?
发布于 2021-07-02 01:06:56
看起来像是JavaScript调试服务器导致了这个问题,因为我使用的是Live Edit插件。当我重新启动服务器时,脚本工作了。而且,如果我只打开html文件,它就能正常工作。但是这个问题总是发生在JavaScript调试服务器第一次启动时,也就是打开浏览器的时候。
快速说明:将脚本放在head标记之间,因为它会将样式表插入到html文件中。
(我正在使用phpStorm中的JavaScript调试服务器)
https://stackoverflow.com/questions/68213832
复制相似问题