首先你的在你的static文件中添加favicon.icon
然后通過以下方式進行修改
1)方式一:修改index.html文件
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico">
這個方式可能存在的問題是,在你切換路由的時候,favicon可能又會出錯,因此建議使用方式二
2)方法二:修改webpack配置文件
build文件夾下面的 webpack.dev.conf.js,webpack.prod.conf.js,修改他們的 HtmlWebpackPlugin 配置對象
new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', inject: true, favicon: path.resolve(__dirname, '../static/favicon.ico') }),
重啟項目工程
