1、最好把favicon.ico放到 index.html放到同一目录(一般为根目录下)
2、在webpack 配置文件里面配置
new HtmlWebpackPlugin({
filename
: 'index.html',
template
: 'index.html',
inject
: true,
favicon
: './favicon.ico'
}),
new HtmlWebpackPlugin({
filename
: config
.build
.index
,
template
: 'index.html',
inject
: true,
favicon
: './favicon.ico',
minify
: {
removeComments
: true,
collapseWhitespace
: true,
removeAttributeQuotes
: true
},
chunksSortMode
: 'dependency'
}),
3、在index.html 中引入图标
<link rel=“shortcut icon” type=“image/x-icon” href="./favicon.ico" />
4、修改完配置文件最好 npm run dev 一下
如果小图标还是没有显示,可尝试清空一下缓存
参考博客
简书-vue 2.0项目 favicon.ico 不显示解决方案