让那个该死的图标显示出来

tech2025-05-05  5

1、最好把favicon.ico放到 index.html放到同一目录(一般为根目录下)

2、在webpack 配置文件里面配置

// 在webpack.dev.conf.js 里面的plugins配置 new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', inject: true, favicon: './favicon.ico' //增加这条 }), // 在 webpack.prod.conf.js 里面的plugins也需要配置 // 否则build的打包完成会找不到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 不显示解决方案

最新回复(0)