vue-cli搭建的vue项目里面已经有了一个static文件夹,用于存放静态文件。
一、将favicon图片放到该文件夹下,然后再index.html中添加:
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico">
刷新浏览器就会更新。
二、如果没有效果,则查看你的build文件夹下:build/webpack.dev.conf.js中:
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon:'../stastic/favicon.ico'
}),
到这个时候,页面的favicon已经可以正常显示了。