reactjs 如何删除默认的 CRA 反应图标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47970778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 04:19:31  来源:igfitidea点击:

How to remove the default CRA react favicon?

reactjscreate-react-app

提问by null

I already remove the link in the head tag and still the favicon gets rendered, is there anyway this can be remove or change?

我已经删除了 head 标签中的链接,但仍然呈现了 favicon,无论如何这可以删除或更改吗?

回答by sudo bangbang

Your favicon is in project_root > public > favicon.ico.

您的图标位于 project_root > public > favicon.ico。

|
`--- public
     |
     `--- favicon.ico

Removing it is hard as browser generally uses a cached favicon if it doesn't find anything.

删除它很困难,因为如果没有找到任何东西,浏览器通常会使用缓存的图标。

I'd urge you to change it. Just replace the favicon.icofile with an image of your choice. You can even rename a png to favicon.icoand use it. Make sure you do a hard refresh. You have to burst cache to see that change.

我劝你改变它。只需用favicon.ico您选择的图像替换文件即可。您甚至可以将 png 重命名为favicon.ico并使用它。确保您进行了硬刷新。您必须突发缓存才能看到这种变化。

If you want to go all in on this, generate a favicon using https://www.favicon-generator.org/

如果您想全力以赴,请使用https://www.favicon-generator.org/生成一个图标

回答by Rajat Rao

Try this:-

尝试这个:-

Change <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />to

更改 <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />

<link rel="shortcut icon" href="/a.png" /> which should be not present by the way or try deleting the favicon 

回答by mostafa tourad

You can change it from the public directory with your own favicon and but you'll see while developemnt but when you run

您可以使用自己的图标从公共目录更改它,但是您会在开发时看到,但是当您运行时

npm run build

you won't see it in the index.html link tag you'll only see it on the development .

你不会在 index.html 链接标签中看到它,你只会在 development 中看到它。

回答by gajo357

You have to do all the above (or below), but you also need to clear your browsing history.

您必须执行以上(或以下)所有操作,但您还需要清除浏览历史记录。

回答by Mue

Go to directory of your project → public → open manifest.json:

转到您的项目目录 → public → open manifest.json

  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    }

回答by Sumit Aggarwal

Change the following icon name with your icon and remove this "%PUBLIC_URL%

使用您的图标更改以下图标名称并删除此“%PUBLIC_URL%

like this

像这样