【问题标题】:Favicon not showing up in VueJSFavicon 没有出现在 VueJS 中
【发布时间】:2020-10-31 22:31:05
【问题描述】:

我正在使用 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.

【问题讨论】:

  • 抱歉,我现在已经编辑好了。
  • 嘿@Jake,这是另一个有用的答案,看到这个,stackoverflow.com/a/40191627/11563561,去一个静态文件夹
  • 其他开发人员的任何东西 :)

标签: vue.js favicon


【解决方案1】:

在 Vuejs 中,您的 favicon.ico 应该位于 public 或 assets 文件夹中。


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


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


希望对你有帮助!!

【讨论】:

  • 谢谢你,非常感谢你的回答。
  • 欢迎@Jake Angelo Vargas!一个upvote将不胜感激!
  • 我试着对你的答案投赞成票,兄弟。但是在我获得 15 声望之前,堆栈不会让我这样做。目前我只有 7 个。
猜你喜欢
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 2020-07-09
  • 1970-01-01
  • 2016-03-17
  • 1970-01-01
  • 2017-11-27
  • 1970-01-01
相关资源
最近更新 更多