如何更改 angular 2 应用程序中的默认图标图标?
How to change default favicon icon in angular 2 app?
- os: win32 x64
- angular-cli: 1.0.0-beta.22-1
- 节点:7.1.0
重现步骤。
删除行
<link rel="icon" type="image/x-icon" href="favicon.ico">
来自 index.html
- ng 构建
- ng 服务
- 浏览 http://localhost:4200/
它仍然显示默认的 angular 图标。
清除浏览器缓存后也尝试了上述步骤,还是一样的问题。
以下浏览器用于重现问题:
- Chrome(版本 54.0.2840.99 m)
- IE(版本 11.0.98600.18499)
将您的图标文件放入 /public 或 /src/assets 文件夹中。这将使您的图标对浏览器可见。参见 the branch on Github.
对于Angular9
我在 /src 中创建了一个 favicon.png 文件并将图像放入文件中
在angular.json中添加文件到assets
"assets": [
"src/favicon.png"
]
- 在index.html中使用这个脚本
<link rel="icon" type="image/x-icon" href="favicon.png">
如果您使用 Chrome,您可能需要清除缓存。
for Windows: CTRL F5
for Mac: CMD SHIFT R
- os: win32 x64
- angular-cli: 1.0.0-beta.22-1
- 节点:7.1.0
重现步骤。
删除行
<link rel="icon" type="image/x-icon" href="favicon.ico">
来自 index.html
- ng 构建
- ng 服务
- 浏览 http://localhost:4200/
它仍然显示默认的 angular 图标。 清除浏览器缓存后也尝试了上述步骤,还是一样的问题。
以下浏览器用于重现问题:
- Chrome(版本 54.0.2840.99 m)
- IE(版本 11.0.98600.18499)
将您的图标文件放入 /public 或 /src/assets 文件夹中。这将使您的图标对浏览器可见。参见 the branch on Github.
对于Angular9
我在 /src 中创建了一个 favicon.png 文件并将图像放入文件中
在angular.json中添加文件到assets
"assets": [
"src/favicon.png"
]
- 在index.html中使用这个脚本
<link rel="icon" type="image/x-icon" href="favicon.png">
如果您使用 Chrome,您可能需要清除缓存。
for Windows: CTRL F5 for Mac: CMD SHIFT R