在 IE 11 中,导航到 Angular 应用程序中的另一个页面时图标消失
In IE 11 the favicon disappears on navigating to another page in Angular application
此问题特定于 Internet Explorer。该图标在 chrome 中运行良好。
我有一个 angular 应用程序,它与遗留应用程序一起 运行。当我从遗留应用程序导航到 angular 应用程序时,图标会按预期出现在 Internet Explorer 中,但是当我在 angular 应用程序中导航时,图标会消失。
<link rel="icon" type="image/x-icon" href="https://cdn.sstatic.net/Sites/Whosebug/img/apple-touch-icon.png?v=c78bd457575a" />
<link rel="shortcut icon" type="image/x-icon" href="https://cdn.sstatic.net/Sites/Whosebug/img/apple-touch-icon.png?v=c78bd457575a" />
我已经尝试了完整路径、相对路径以及 CDN,但似乎没有任何效果。
我确实遇到了这个问题,这似乎为我解决了这个问题:
在您的 index.html 文件中:
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
然后您必须确保在您的 angular.json 文件的资产中包含网站图标:
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico", //Right here
"web.config",
"environments"
],
最后,确保您的图标名为 favicon.ico,并且它位于项目的 src 文件夹中。有在线工具可以将图像转换为 .ico 文件,以防您使用不同的格式。
此问题特定于 Internet Explorer。该图标在 chrome 中运行良好。 我有一个 angular 应用程序,它与遗留应用程序一起 运行。当我从遗留应用程序导航到 angular 应用程序时,图标会按预期出现在 Internet Explorer 中,但是当我在 angular 应用程序中导航时,图标会消失。
<link rel="icon" type="image/x-icon" href="https://cdn.sstatic.net/Sites/Whosebug/img/apple-touch-icon.png?v=c78bd457575a" />
<link rel="shortcut icon" type="image/x-icon" href="https://cdn.sstatic.net/Sites/Whosebug/img/apple-touch-icon.png?v=c78bd457575a" />
我已经尝试了完整路径、相对路径以及 CDN,但似乎没有任何效果。
我确实遇到了这个问题,这似乎为我解决了这个问题:
在您的 index.html 文件中:
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
然后您必须确保在您的 angular.json 文件的资产中包含网站图标:
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico", //Right here
"web.config",
"environments"
],
最后,确保您的图标名为 favicon.ico,并且它位于项目的 src 文件夹中。有在线工具可以将图像转换为 .ico 文件,以防您使用不同的格式。