javascript 如何使用 Meteor 加载网站图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20054788/
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
How to load a favicon with Meteor
提问by bgmaster
I'm trying to figure out how to add a favicon to my meteor app. Per the docs I should put it in the /public
directory, but there isn't really much more info than that. I put my favicon.ico
file there and referenced it in the header of my html file, but the browser doesn't load it. If I open up the dev tools on chrome though, it shows the file loading (i.e., go to localhost:3000/favicon.ico
). Anyone have any suggestions on what I might be missing?
我想弄清楚如何向我的流星应用程序添加图标。根据文档,我应该把它放在/public
目录中,但没有比这更多的信息了。我把我的favicon.ico
文件放在那里并在我的 html 文件的标题中引用它,但浏览器没有加载它。但是,如果我在 chrome 上打开开发工具,它会显示文件加载(即转到localhost:3000/favicon.ico
)。有人对我可能缺少的东西有任何建议吗?
回答by alanning
It should work. Probably either an issue with the path or caching on localhost.
它应该工作。可能是路径问题或本地主机上的缓存。
Here's how the favicon should be linked:
以下是链接图标的方式:
<link rel="icon" sizes="16x16 32x32" href="/favicon.ico?v=2">
(Note: the /
in the beginning; its important!)
(注意:一/
开始;它很重要!)
回答by Daniel Bernhard
Not sure what your path is like. Everything in the public folder is slapped together and accessible at root, so perhaps try /favicon.png
.
不确定你的路径是什么样的。公用文件夹中的所有内容都放在一起并且可以在根目录下访问,所以也许试试/favicon.png
.
回答by sandman
I added the favicon.ico in the /public/ directory of my meteor project and it showed up for me!
我在我的流星项目的 /public/ 目录中添加了 favicon.ico,它出现了!
didn't have to add any lines of code
不必添加任何代码行
also if its caching issue maybe rename the favicon.ico to favicon2.ico
如果它的缓存问题可能将 favicon.ico 重命名为 favicon2.ico