Favicon 没有出现在 VueJS 中

Favicon not showing up in VueJS

我正在使用 Vue JS 技术进行编码,我正在尝试加载网站图标,但它不会显示。我试图寻找有关它的其他文档,但找不到。我是这项技术的初学者,希望有人能提供帮助。谢谢!

这是我在 HTML 中的代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="favicon.ico" />
<title>Hello World</title>
</head>
<body>

<noscript>
  <strong>
   We're sorry but codesandbox doesn't work properly without 
   JavaScript enabled. Please enable it to continue.
 </strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->

Please check the attached image there is the code as well.

在 Vuejs 中,您的 favicon.ico 应该在 public 或资产文件夹中。


要从 vue 中的 assets 文件夹访问图像,可以这样做:src="require('@/assets/images/favicon.ico')"


要在 vue 中访问 public 文件夹中的图像,可以这样做:src="./static/images/favicon.ico"


希望对您有所帮助!!