简体   繁体   English

如何更改 Angular 中的 favicon.ico 路径?

[英]How to change favicon.ico path in Angular?

I am new to Angular.我是 Angular 的新手。 In my angular app environment, there will be a base path after DNS name like https://my-server-name/my-angular-app-name.在我的 angular 应用程序环境中,在 DNS 名称之后会有一个基本路径,例如 https://my-server-name/my-angular-app-name。

There is also a server side restriction like only requests that matches with base path of "my-angular-app-name", will pass through the server.还有一个服务器端限制,例如只有与“my-angular-app-name”基本路径匹配的请求才会通过服务器。 All other requests that does not match the path will be terminated.所有其他与路径不匹配的请求将被终止。

I was able to give the base path in the app using ng build --deploy-url /my-angular-app-name/ command.我能够使用 ng build --deploy-url /my-angular-app-name/ 命令在应用程序中提供基本路径。 This command is adding a base path of /my-angular-app-name in all the Java Script files that index.html needs.此命令在 index.html 需要的所有 Java 脚本文件中添加 /my-angular-app-name 的基本路径。 But this command is not updating the path of favicon.ico file.但是这个命令不会更新 favicon.ico 文件的路径。

Is there any ways that I can give a custom path to favicon.ico file?有什么方法可以为 favicon.ico 文件提供自定义路径吗?

  1. Add your favicon inside the src folder.src文件夹中添加您的网站图标。

  2. Open the heindex.html file and change the favicon file name (with the newly added icon name).打开 heindex.html 文件并更改 favicon 文件名(使用新添加的图标名称)。

<link rel="icon" type="image/x-icon" href="favicon.ico"/>

Inside the angular.json file add the favicon in assets array.在 angular.json 文件中,在 assets 数组中添加 favicon。

Reference here参考这里

"assets": [
    "src/assets",
    "src/favicon.ico"
],

Dis you check the config in angular.json and in manifest.json?您是否检查了 angular.json 和 manifest.json 中的配置?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM